25 #define DEBUG_TYPE "ssaupdaterbulk" 31 auto *
User = cast<Instruction>(U->getUser());
33 if (
auto *UserPN = dyn_cast<PHINode>(
User))
34 return UserPN->getIncomingBlock(*U);
36 return User->getParent();
42 unsigned Var = Rewrites.
size();
43 LLVM_DEBUG(
dbgs() <<
"SSAUpdater: Var=" << Var <<
": initialized with Ty = " 44 << *Ty <<
", Name = " << Name <<
"\n");
45 RewriteInfo RI(Name, Ty);
53 assert(Var < Rewrites.
size() &&
"Variable not found!");
55 <<
": added new available value" << *V <<
" in " 57 Rewrites[Var].Defines[BB] = V;
63 assert(Var < Rewrites.
size() &&
"Variable not found!");
64 LLVM_DEBUG(
dbgs() <<
"SSAUpdater: Var=" << Var <<
": added a use" << *U->get()
72 return (Var < Rewrites.
size()) ? Rewrites[Var].Defines.count(BB) :
false;
79 if (!R.Defines.count(BB)) {
82 Value *V = computeValueAt(IDom, R, DT);
105 while (!LiveInBlockWorklist.empty()) {
106 BasicBlock *BB = LiveInBlockWorklist.pop_back_val();
110 if (!LiveInBlocks.
insert(BB).second)
122 LiveInBlockWorklist.push_back(
P);
131 for (
auto &R : Rewrites) {
142 for (
auto &
Def : R.Defines)
147 for (
Use *U : R.Uses)
159 for (
auto *FrontierBB : IDFBlocks) {
161 PHINode *PN =
B.CreatePHI(R.Ty, 0, R.Name);
162 R.Defines[FrontierBB] = PN;
169 for (
auto *PN : InsertedPHIsForVar) {
172 PN->addIncoming(computeValueAt(Pred, R, DT), Pred);
177 for (
Use *U : R.Uses) {
178 if (!ProcessedUses.
insert(U).second)
181 Value *OldVal = U->get();
182 assert(OldVal &&
"Invalid use!");
186 LLVM_DEBUG(
dbgs() <<
"SSAUpdater: replacing " << *OldVal <<
" with " << *V
This class represents lattice values for constants.
void push_back(const T &Elt)
bool hasValueHandle() const
Return true if there is a value handle associated with this value.
This defines the Use class.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
ArrayRef< BasicBlock * > get(BasicBlock *BB)
unsigned AddVariable(StringRef Name, Type *Ty)
Add a new variable to the SSA rewriter.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
A Use represents the edge between a Value definition and its users.
void setDefiningBlocks(const SmallPtrSetImpl< BasicBlock *> &Blocks)
Give the IDF calculator the set of blocks in which the value is defined.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
void AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value...
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries...
static void ValueIsRAUWd(Value *Old, Value *New)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
static void ComputeLiveInBlocks(const SmallPtrSetImpl< BasicBlock *> &UsingBlocks, const SmallPtrSetImpl< BasicBlock *> &DefBlocks, SmallPtrSetImpl< BasicBlock *> &LiveInBlocks, PredIteratorCache &PredCache)
Given sets of UsingBlocks and DefBlocks, compute the set of LiveInBlocks.
DomTreeNodeBase * getIDom() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void resetLiveInBlocks()
Reset the live-in block set to be empty, and tell the IDF calculator to not use liveness anymore...
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
void AddUse(unsigned Var, Use *U)
Record a use of the symbolic value.
Compute iterated dominance frontiers using a linear time algorithm.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
void setLiveInBlocks(const SmallPtrSetImpl< BasicBlock *> &Blocks)
Give the IDF calculator the set of blocks in which the value is live on entry to the block...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
void calculate(SmallVectorImpl< BasicBlock *> &IDFBlocks)
Calculate iterated dominance frontiers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void RewriteAllUses(DominatorTree *DT, SmallVectorImpl< PHINode *> *InsertedPHIs=nullptr)
Perform all the necessary updates, including new PHI-nodes insertion and the requested uses update...
StringRef getName() const
Return a constant reference to the value's name.
const Function * getParent() const
Return the enclosing method, or null if none.
Determine the iterated dominance frontier, given a set of defining blocks, and optionally, a set of live-in blocks.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
bool HasValueForBlock(unsigned Var, BasicBlock *BB)
Return true if the SSAUpdater already has a value for the specified variable in the specified block...
static BasicBlock * getUserBB(Use *U)
Helper function for finding a block which should have a value for the given user. ...