16 #ifndef LLVM_TRANSFORMS_SCALAR_GVN_H
17 #define LLVM_TRANSFORMS_SCALAR_GVN_H
32 class OptimizationRemarkEmitter;
37 struct AvailableValue;
38 struct AvailableValueInBlock;
56 InstrsToErase.push_back(I);
120 struct LeaderTableEntry {
123 LeaderTableEntry *Next;
145 LeaderTableEntry &Curr = LeaderTable[
N];
152 LeaderTableEntry *Node = TableAllocator.
Allocate<LeaderTableEntry>();
155 Node->Next = Curr.Next;
162 LeaderTableEntry *Prev =
nullptr;
163 LeaderTableEntry *Curr = &LeaderTable[
N];
165 while (Curr && (Curr->Val != I || Curr->BB != BB)) {
174 Prev->Next = Curr->Next;
180 LeaderTableEntry *Next = Curr->Next;
181 Curr->Val = Next->Val;
183 Curr->Next = Next->Next;
189 SmallVector<std::pair<TerminatorInst *, unsigned>, 4> toSplit;
192 bool processLoad(LoadInst *
L);
193 bool processNonLocalLoad(LoadInst *
L);
194 bool processAssumeIntrinsic(IntrinsicInst *II);
198 bool AnalyzeLoadAvailability(LoadInst *LI, MemDepResult DepInfo,
199 Value *
Address, gvn::AvailableValue &Res);
203 void AnalyzeLoadAvailability(LoadInst *LI, LoadDepVect &Deps,
204 AvailValInBlkVect &ValuesPerBlock,
205 UnavailBlkVect &UnavailableBlocks);
206 bool PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock,
207 UnavailBlkVect &UnavailableBlocks);
210 bool processInstruction(Instruction *I);
212 void dump(DenseMap<uint32_t, Value *> &d);
213 bool iterateOnFunction(Function &F);
214 bool performPRE(Function &F);
215 bool performScalarPRE(Instruction *I);
216 bool performScalarPREInsertion(Instruction *Instr,
BasicBlock *Pred,
219 void cleanupGlobalSets();
220 void verifyRemoved(
const Instruction *I)
const;
221 bool splitCriticalEdges();
223 bool replaceOperandsWithConsts(Instruction *I)
const;
224 bool propagateEquality(Value *LHS, Value *RHS,
const BasicBlockEdge &Root,
225 bool DominatesByEdge);
226 bool processFoldableCondBr(BranchInst *BI);
228 void assignValNumForDeadCode();
void setDomTree(DominatorTree *D)
FunctionPass * createGVNPass(bool NoLoads=false)
Create a legacy GVN pass.
Provides a lazy, caching interface for making common memory aliasing information queries, backed by LLVM's alias analysis passes.
uint32_t lookupOrAddCmp(unsigned Opcode, CmpInst::Predicate Pred, Value *LHS, Value *RHS)
Returns the value number of the given comparison, assigning it a new number if it did not have one be...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
This class represents a function call, abstracting a target machine's calling convention.
A cache of .assume calls within a function.
bool exists(Value *V) const
Returns true if a value number exists for the specified value.
void setAliasAnalysis(AliasAnalysis *A)
AliasAnalysis * getAliasAnalysis() const
A simple and fast domtree-based GVN pass to hoist common expressions from sibling branches...
void clear()
Remove all entries from the ValueTable.
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
A MapVector that performs no allocations if smaller than a certain size.
The core GVN pass object.
A CRTP mix-in to automatically provide informational APIs needed for passes.
void add(Value *V, uint32_t num)
add - Insert a value into the table with a specified value number.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
This class holds the mapping between values and value numbers.
Allocate memory in an ever growing pool, as if by bump-pointer.
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
DominatorTree & getDominatorTree() const
void markInstructionForDeletion(Instruction *I)
This removes the specified instruction from our various maps and marks it for deletion.
AliasAnalysis * getAliasAnalysis() const
void verifyRemoved(const Value *) const
verifyRemoved - Verify that the value is removed from all internal data structures.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Provides information about what library functions are available for the current target.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void erase(Value *v)
Remove a value from the value numbering.
void setMemDep(MemoryDependenceResults *M)
uint32_t lookupOrAdd(Value *V)
lookup_or_add - Returns the value number for the specified value, assigning it a new number if it did...
uint32_t lookup(Value *V) const
Returns the value number of the specified value.
uint32_t getNextUnusedValueNumber()
LLVM Value Representation.
A vector that has set insertion semantics.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
MemoryDependenceResults & getMemDep() const