Go to the documentation of this file.
24 #define DEBUG_TYPE "ssaupdaterbulk"
30 auto *
User = cast<Instruction>(U->getUser());
32 if (
auto *UserPN = dyn_cast<PHINode>(
User))
33 return UserPN->getIncomingBlock(*U);
35 return User->getParent();
41 unsigned Var = Rewrites.size();
42 LLVM_DEBUG(
dbgs() <<
"SSAUpdater: Var=" << Var <<
": initialized with Ty = "
43 << *Ty <<
", Name = " <<
Name <<
"\n");
44 RewriteInfo RI(
Name, Ty);
45 Rewrites.push_back(RI);
52 assert(Var < Rewrites.size() &&
"Variable not found!");
54 <<
": added new available value" << *V <<
" in "
55 <<
BB->getName() <<
"\n");
56 Rewrites[Var].Defines[
BB] = V;
62 assert(Var < Rewrites.size() &&
"Variable not found!");
63 LLVM_DEBUG(
dbgs() <<
"SSAUpdater: Var=" << Var <<
": added a use" << *U->get()
65 Rewrites[Var].Uses.push_back(U);
72 if (!R.Defines.count(
BB)) {
75 Value *V = computeValueAt(IDom, R, DT);
98 while (!LiveInBlockWorklist.empty()) {
103 if (!LiveInBlocks.
insert(
BB).second)
115 LiveInBlockWorklist.push_back(
P);
124 for (
auto &R : Rewrites) {
135 for (
auto &
Def : R.Defines)
140 for (
Use *U : R.Uses)
152 for (
auto *FrontierBB : IDFBlocks) {
154 PHINode *PN =
B.CreatePHI(R.Ty, 0, R.Name);
155 R.Defines[FrontierBB] = PN;
156 InsertedPHIsForVar.push_back(PN);
158 InsertedPHIs->push_back(PN);
162 for (
auto *PN : InsertedPHIsForVar) {
165 PN->addIncoming(computeValueAt(Pred, R, DT), Pred);
170 for (
Use *U : R.Uses) {
171 if (!ProcessedUses.
insert(U).second)
174 Value *OldVal = U->get();
175 assert(OldVal &&
"Invalid use!");
179 LLVM_DEBUG(
dbgs() <<
"SSAUpdater: replacing " << *OldVal <<
" with " << *V
static StringRef getName(Value *V)
This is an optimization pass for GlobalISel generic memory operations.
void setLiveInBlocks(const SmallPtrSetImpl< NodeTy * > &Blocks)
Give the IDF calculator the set of blocks in which the value is live on entry to the block.
const Function * getParent() const
Return the enclosing method, or null if none.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries.
void AddUse(unsigned Var, Use *U)
Record a use of the symbolic value.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
The instances of the Type class are immutable: once they are created, they are never changed.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
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.
LLVM_NODISCARD T pop_back_val()
DomTreeNodeBase * getIDom() const
void calculate(SmallVectorImpl< NodeTy * > &IDFBlocks)
Calculate iterated dominance frontiers.
LLVM Basic Block Representation.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void resetLiveInBlocks()
Reset the live-in block set to be empty, and tell the IDF calculator to not use liveness anymore.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static void ValueIsRAUWd(Value *Old, Value *New)
bool hasValueHandle() const
Return true if there is a value handle associated with this value.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
void setDefiningBlocks(const SmallPtrSetImpl< NodeTy * > &Blocks)
Give the IDF calculator the set of blocks in which the value is defined.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
StringRef - Represent a constant reference to a string, i.e.
unsigned AddVariable(StringRef Name, Type *Ty)
Add a new variable to the SSA rewriter.
void AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value.
static BasicBlock * getUserBB(Use *U)
Helper function for finding a block which should have a value for the given user.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
ArrayRef< BasicBlock * > get(BasicBlock *BB)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
LLVM Value Representation.
void RewriteAllUses(DominatorTree *DT, SmallVectorImpl< PHINode * > *InsertedPHIs=nullptr)
Perform all the necessary updates, including new PHI-nodes insertion and the requested uses update.
A Use represents the edge between a Value definition and its users.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.