19 #define DEBUG_TYPE "reg2mem"
33 STATISTIC(NumRegsDemoted,
"Number of registers demoted");
34 STATISTIC(NumPhisDemoted,
"Number of phi-nodes demoted");
70 bool RegToMem::runOnFunction(
Function &
F) {
71 if (F.isDeclaration())
77 "Entry block to function must not have predecessors!");
83 while (isa<AllocaInst>(I)) ++
I;
88 "reg2mem alloca point", I);
92 std::list<Instruction*> WorkList;
97 if (!(isa<AllocaInst>(iib) && iib->getParent() == BBEntry) &&
99 WorkList.push_front(&*iib);
104 NumRegsDemoted += WorkList.size();
105 for (std::list<Instruction*>::iterator ilb = WorkList.begin(),
106 ile = WorkList.end(); ilb != ile; ++ilb)
116 if (isa<PHINode>(iib))
117 WorkList.push_front(&*iib);
120 NumPhisDemoted += WorkList.size();
121 for (std::list<Instruction*>::iterator ilb = WorkList.begin(),
122 ile = WorkList.end(); ilb != ile; ++ilb)
132 return new RegToMem();
static PassRegistry * getPassRegistry()
char & DemoteRegisterToMemoryID
AllocaInst * DemoteRegToStack(Instruction &X, bool VolatileLoads=false, Instruction *AllocaPoint=0)
ValuesClass< DataType > END_WITH_NULL values(const char *Arg, DataType Val, const char *Desc,...)
FunctionPass * createDemoteRegisterToMemoryPass()
static Constant * getNullValue(Type *Ty)
#define INITIALIZE_PASS_DEPENDENCY(depName)
STATISTIC(NumRegsDemoted,"Number of registers demoted")
Base class of casting instructions.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
ID
LLVM Calling Convention Representation.
This class represents a no-op cast from one type to another.
AnalysisUsage & addPreservedID(const void *ID)
INITIALIZE_PASS_BEGIN(RegToMem,"reg2mem","Demote all values to stack slots", false, false) INITIALIZE_PASS_END(RegToMem
Demote all values to stack false
LLVM Basic Block Representation.
char & BreakCriticalEdgesID
Interval::pred_iterator pred_begin(Interval *I)
Demote all values to stack slots
AllocaInst * DemotePHIToStack(PHINode *P, Instruction *AllocaPoint=0)
Interval::pred_iterator pred_end(Interval *I)
void initializeRegToMemPass(PassRegistry &)
AnalysisUsage & addRequiredID(const void *ID)
static IntegerType * getInt32Ty(LLVMContext &C)
const BasicBlock * getParent() const