25 #define DEBUG_TYPE "mem2reg"
27 STATISTIC(NumPromoted,
"Number of alloca's promoted");
61 bool PromotePass::runOnFunction(
Function &
F) {
62 std::vector<AllocaInst*> Allocas;
68 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
70 getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
80 Allocas.push_back(AI);
82 if (Allocas.empty())
break;
85 NumPromoted += Allocas.size();
95 return new PromotePass();
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
STATISTIC(NumFunctions,"Total number of functions")
This class provides various memory handling functions that manipulate MemoryBlock instances...
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of .assume calls within a function.
bool isAllocaPromotable(const AllocaInst *AI)
Return true if this alloca is legal for promotion.
void initializePromotePassPass(PassRegistry &)
iterator begin()
Instruction iterator methods.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
void PromoteMemToReg(ArrayRef< AllocaInst * > Allocas, DominatorTree &DT, AliasSetTracker *AST=nullptr, AssumptionCache *AC=nullptr)
Promote the specified list of alloca instructions into scalar registers, inserting PHI nodes as appro...
AnalysisUsage & addPreservedID(const void *ID)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
LLVM Basic Block Representation.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Promote Memory to Register
void setPreservesCFG()
This function should be called by the pass, iff they do not:
INITIALIZE_PASS_BEGIN(PromotePass,"mem2reg","Promote Memory to Register", false, false) INITIALIZE_PASS_END(PromotePass
FunctionPass * createPromoteMemoryToRegisterPass()
Legacy analysis pass which computes a DominatorTree.
AllocaInst - an instruction to allocate memory on the stack.