#include "PPC.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopIterator.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#define DEBUG_TYPE …
STATISTIC(NumPooledStrings, "Number of Strings Pooled");
usingnamespacellvm;
static cl::opt<unsigned>
MaxStringsPooled("ppc-max-strings-pooled", cl::Hidden, cl::init(-1),
cl::desc("Maximum Number of Strings to Pool."));
static cl::opt<unsigned>
MinStringsBeforePool("ppc-min-strings-before-pool", cl::Hidden, cl::init(2),
cl::desc("Minimum number of string candidates before "
"pooling is considered."));
namespace {
struct { … } CompareConstants;
class PPCMergeStringPool : public ModulePass { … };
static bool hasReplaceableUsers(GlobalVariable &GV) { … }
void PPCMergeStringPool::collectCandidateConstants(Module &M) { … }
bool PPCMergeStringPool::mergeModuleStringPool(Module &M) { … }
void PPCMergeStringPool::replaceUsesWithGEP(GlobalVariable *GlobalToReplace,
GlobalVariable *GPool,
unsigned ElementIndex) { … }
}
char PPCMergeStringPool::ID = …;
INITIALIZE_PASS(…)
ModulePass *llvm::createPPCMergeStringPoolPass() { … }