33 #define DEBUG_TYPE "reg2mem" 35 STATISTIC(NumRegsDemoted,
"Number of registers demoted");
36 STATISTIC(NumPhisDemoted,
"Number of phi-nodes demoted");
54 if (UI->
getParent() != BB || isa<PHINode>(UI))
72 if (F.isDeclaration() || skipFunction(F))
78 "Entry block to function must not have predecessors!");
84 while (isa<AllocaInst>(I)) ++
I;
92 std::list<Instruction*> WorkList;
96 if (!(isa<AllocaInst>(iib) && iib->getParent() == BBEntry) &&
97 valueEscapes(&*iib)) {
98 WorkList.push_front(&*iib);
103 NumRegsDemoted += WorkList.size();
113 if (isa<PHINode>(iib))
114 WorkList.push_front(&*iib);
117 NumPhisDemoted += WorkList.size();
128 return new RegToMem();
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 ...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
char & DemoteRegisterToMemoryID
STATISTIC(NumFunctions, "Total number of functions")
FunctionPass * createDemoteRegisterToMemoryPass()
INITIALIZE_PASS_BEGIN(RegToMem, "reg2mem", "Demote all values to stack slots", false, false) INITIALIZE_PASS_END(RegToMem
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
iterator begin()
Instruction iterator methods.
#define INITIALIZE_PASS_DEPENDENCY(depName)
This is the base class for all instructions that perform data casts.
Predicate all(Predicate P0, Predicate P1)
True iff P0 and P1 are true.
This class represents a no-op cast from one type to another.
AnalysisUsage & addPreservedID(const void *ID)
static bool runOnFunction(Function &F, bool PostInlining)
LLVM Basic Block Representation.
char & BreakCriticalEdgesID
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Demote all values to stack slots
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
bool pred_empty(const BasicBlock *BB)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
void initializeRegToMemPass(PassRegistry &)
Iterator for intrusive lists based on ilist_node.
AnalysisUsage & addRequiredID(const void *ID)
Module.h This file contains the declarations for the Module class.
iterator_range< user_iterator > users()
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
static IntegerType * getInt32Ty(LLVMContext &C)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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...
const BasicBlock * getParent() const