35#define DEBUG_TYPE "reg2mem"
37STATISTIC(NumRegsDemoted,
"Number of registers demoted");
38STATISTIC(NumPhisDemoted,
"Number of phi-nodes demoted");
47 if (UI->
getParent() != BB || isa<PHINode>(UI))
57 "Entry block to function must not have predecessors!");
63 while (isa<AllocaInst>(
I)) ++
I;
71 std::list<Instruction*> WorkList;
73 if (!(isa<AllocaInst>(
I) &&
I.getParent() == BBEntry) &&
valueEscapes(
I))
74 WorkList.push_front(&
I);
77 NumRegsDemoted += WorkList.size();
85 for (
auto &Phi : BB.phis())
86 WorkList.push_front(&Phi);
89 NumPhisDemoted += WorkList.size();
101 if (
N == 0 && !Changed)
Expand Atomic instructions
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
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.
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.
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.
Analysis pass that exposes the LoopInfo for a function.
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()
const ParentTy * getParent() const
self_iterator getIterator()
This is an optimization pass for GlobalISel generic memory operations.
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...
bool pred_empty(const BasicBlock *BB)
Option class for critical edge splitting.