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();
76 bool runOnFunction(
Function &
F)
override {
80 DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
82 getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
106 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)
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...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
A set of analyses that are preserved following a run of a transformation pass.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
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.
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 &)
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