37#define DEBUG_TYPE "reg2mem"
39STATISTIC(NumRegsDemoted,
"Number of registers demoted");
40STATISTIC(NumPhisDemoted,
"Number of phi-nodes demoted");
49 if (UI->
getParent() != BB || isa<PHINode>(UI))
59 "Entry block to function must not have predecessors!");
65 while (isa<AllocaInst>(
I)) ++
I;
73 std::list<Instruction*> WorkList;
75 if (!(isa<AllocaInst>(
I) &&
I.getParent() == BBEntry) &&
valueEscapes(
I))
76 WorkList.push_front(&
I);
79 NumRegsDemoted += WorkList.size();
87 for (
auto &Phi : BB.phis())
88 WorkList.push_front(&Phi);
91 NumPhisDemoted += WorkList.size();
103 if (
N == 0 && !Changed)
124 if (
F.isDeclaration() || skipFunction(
F))
131char RegToMemLegacy::ID = 0;
133 "Demote all values to stack slots",
false,
false)
141 return new RegToMemLegacy();
Mark the given Function as meaning that it cannot be changed in any way mark any values that are used as this function s parameters or by its return values(according to Uses) live as well. void DeadArgumentEliminationPass
static bool runOnFunction(Function &F, bool PostInlining)
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
print must be executed print the must be executed context for all instructions
static cl::opt< bool > SplitAllCriticalEdges("phi-elim-split-all-critical-edges", cl::init(false), cl::Hidden, cl::desc("Split all critical edges during " "PHI elimination"))
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static bool valueEscapes(const Instruction &Inst)
static bool runPass(Function &F)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Merge disjoint stack slots
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequiredID(const void *ID)
AnalysisUsage & addPreservedID(const void *ID)
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
InstListType::iterator iterator
Instruction iterators...
This class represents a no-op cast from one type to another.
This is the base class for all instructions that perform data casts.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Analysis pass which computes a DominatorTree.
FunctionPass class - This class is used to implement most global optimizations.
const BasicBlock * getParent() const
Analysis pass that exposes the LoopInfo for a function.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void preserve()
Mark an analysis as preserved.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
static IntegerType * getInt32Ty(LLVMContext &C)
Type * getType() const
All values are typed, get the type of this value.
iterator_range< user_iterator > users()
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
void initializeRegToMemLegacyPass(PassRegistry &)
FunctionPass * createDemoteRegisterToMemoryPass()
char & DemoteRegisterToMemoryID
char & BreakCriticalEdgesID
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 ...
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...
Option class for critical edge splitting.