Go to the documentation of this file.
37 #define DEBUG_TYPE "reg2mem"
39 STATISTIC(NumRegsDemoted,
"Number of registers demoted");
40 STATISTIC(NumPhisDemoted,
"Number of phi-nodes demoted");
56 "Entry block to function must not have predecessors!");
62 while (isa<AllocaInst>(
I)) ++
I;
70 std::list<Instruction*> WorkList;
72 if (!(isa<AllocaInst>(
I) &&
I.getParent() == BBEntry) &&
valueEscapes(
I))
73 WorkList.push_front(&
I);
76 NumRegsDemoted += WorkList.size();
84 for (
auto &Phi :
BB.phis())
85 WorkList.push_front(&Phi);
88 NumPhisDemoted += WorkList.size();
100 if (
N == 0 && !Changed)
121 if (
F.isDeclaration() || skipFunction(
F))
130 "Demote all values to stack slots",
false,
false)
138 return new RegToMemLegacy();
A set of analyses that are preserved following a run of a transformation pass.
This is an optimization pass for GlobalISel generic memory operations.
InstListType::iterator iterator
Instruction iterators...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents a no-op cast from one type to another.
char & DemoteRegisterToMemoryID
static bool runPass(Function &F)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM Basic Block Representation.
Demote all values to stack slots
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AllocaInst * DemotePHIToStack(PHINode *P, Instruction *AllocaPoint=nullptr)
This function takes a virtual register computed by a phi node and replaces it with a slot in the stac...
iterator begin()
Instruction iterator methods.
Represent the analysis usage information of a pass.
Option class for critical edge splitting.
static bool valueEscapes(const Instruction &Inst)
STATISTIC(NumFunctions, "Total number of functions")
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
INITIALIZE_PASS_BEGIN(RegToMemLegacy, "reg2mem", "Demote all values to stack slots", false, false) INITIALIZE_PASS_END(RegToMemLegacy
inst_range instructions(Function *F)
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
void preserve()
Mark an analysis as preserved.
Predicate all(Predicate P0, Predicate P1)
True iff P0 and P1 are true.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunctionPass * createDemoteRegisterToMemoryPass()
void initializeRegToMemLegacyPass(PassRegistry &)
AnalysisUsage & addPreservedID(const void *ID)
bool pred_empty(const BasicBlock *BB)
AllocaInst * DemoteRegToStack(Instruction &X, bool VolatileLoads=false, Instruction *AllocaPoint=nullptr)
This function takes a virtual register computed by an Instruction and replaces it with a slot in the ...
This is the base class for all instructions that perform data casts.
static bool runOnFunction(Function &F, bool PostInlining)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
char & BreakCriticalEdgesID
Analysis pass which computes a DominatorTree.
unsigned SplitAllCriticalEdges(Function &F, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions())
Loop over all of the edges in the CFG, breaking critical edges as they are found.
const BasicBlock * getParent() const
S is passed via registers r2 But gcc stores them to the stack
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
AnalysisUsage & addRequiredID(const void *ID)
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
iterator_range< user_iterator > users()
Analysis pass that exposes the LoopInfo for a function.