36#define DEBUG_TYPE "reg2mem"
38STATISTIC(NumRegsDemoted,
"Number of registers demoted");
39STATISTIC(NumPhisDemoted,
"Number of phi-nodes demoted");
48 if (UI->
getParent() != BB || isa<PHINode>(UI))
58 "Entry block to function must not have predecessors!");
64 while (isa<AllocaInst>(
I)) ++
I;
72 std::list<Instruction*> WorkList;
74 if (!(isa<AllocaInst>(
I) &&
I.getParent() == BBEntry) &&
valueEscapes(
I))
75 WorkList.push_front(&
I);
78 NumRegsDemoted += WorkList.size();
86 for (
auto &Phi : BB.phis())
87 WorkList.push_front(&Phi);
90 NumPhisDemoted += WorkList.size();
102 if (
N == 0 && !Changed)
131 DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
132 LoopInfo *LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
136 return N != 0 || Changed;
Expand Atomic instructions
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
This header defines various interfaces for pass management in LLVM.
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"))
#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())
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 & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
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.
Legacy analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
FunctionPass class - This class is used to implement most global optimizations.
Analysis pass that exposes the LoopInfo for a function.
The legacy pass manager's analysis pass to compute loop information.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
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)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
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()
const ParentTy * getParent() const
self_iterator getIterator()
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createRegToMemWrapperPass()
AllocaInst * DemoteRegToStack(Instruction &X, bool VolatileLoads=false, std::optional< BasicBlock::iterator > AllocaPoint=std::nullopt)
This function takes a virtual register computed by an Instruction and replaces it with a slot in the ...
AllocaInst * DemotePHIToStack(PHINode *P, std::optional< BasicBlock::iterator > AllocaPoint=std::nullopt)
This function takes a virtual register computed by a phi node and replaces it with a slot in the stac...
void initializeRegToMemWrapperPassPass(PassRegistry &)
bool pred_empty(const BasicBlock *BB)
Option class for critical edge splitting.