26 #define DEBUG_TYPE "mem2reg"
28 STATISTIC(NumPromoted,
"Number of alloca's promoted");
32 std::vector<AllocaInst *> Allocas;
44 Allocas.push_back(AI);
50 NumPromoted += Allocas.size();
77 bool runOnFunction(
Function &
F)
override {
81 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
83 getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
107 return new PromoteLegacyPass();
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.
Analysis pass which computes a DominatorTree.
bool isAllocaPromotable(const AllocaInst *AI)
Return true if this alloca is legal for promotion.
iterator begin()
Instruction iterator methods.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
FunctionPass * createPromoteMemoryToRegisterPass()
Represent the analysis usage information of a pass.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A function analysis which provides an AssumptionCache.
Iterator for intrusive lists based on ilist_node.
void PromoteMemToReg(ArrayRef< AllocaInst * > Allocas, DominatorTree &DT, AssumptionCache *AC=nullptr)
Promote the specified list of alloca instructions into scalar registers, inserting PHI nodes as appro...
static bool promoteMemoryToRegister(Function &F, DominatorTree &DT, AssumptionCache &AC)
Promote Memory to Register
void setPreservesCFG()
This function should be called by the pass, iff they do not:
const BasicBlock & getEntryBlock() const
void initializePromoteLegacyPassPass(PassRegistry &)
Represents analyses that only rely on functions' control flow.
void preserveSet()
Mark an analysis set as preserved.
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
an instruction to allocate memory on the stack
INITIALIZE_PASS_BEGIN(PromoteLegacyPass,"mem2reg","Promote Memory to ""Register", false, false) INITIALIZE_PASS_END(PromoteLegacyPass