46 #define DEBUG_TYPE "dse"
48 STATISTIC(NumRedundantStores,
"Number of redundant stores deleted");
49 STATISTIC(NumFastStores,
"Number of stores deleted");
50 STATISTIC(NumFastOther ,
"Number of other instrs removed");
51 STATISTIC(NumCompletePartials,
"Number of stores dead by later partials");
56 cl::desc(
"Enable partial-overwrite tracking in DSE"));
106 if (ValueSet) ValueSet->remove(DeadInst);
107 InstrOrdering->
erase(DeadInst);
114 }
while (!NowDeadInsts.
empty());
121 if (isa<StoreInst>(I))
124 switch (II->getIntrinsicID()) {
127 case Intrinsic::memset:
128 case Intrinsic::memmove:
129 case Intrinsic::memcpy:
130 case Intrinsic::init_trampoline:
131 case Intrinsic::lifetime_end:
136 if (
Function *
F = CS.getCalledFunction()) {
138 if (TLI.
has(LibFunc_strcpy) && FnName == TLI.
getName(LibFunc_strcpy))
140 if (TLI.
has(LibFunc_strncpy) && FnName == TLI.
getName(LibFunc_strncpy))
142 if (TLI.
has(LibFunc_strcat) && FnName == TLI.
getName(LibFunc_strcat))
144 if (TLI.
has(LibFunc_strncat) && FnName == TLI.
getName(LibFunc_strncat))
171 case Intrinsic::init_trampoline:
175 case Intrinsic::lifetime_end: {
176 uint64_t Len = cast<ConstantInt>(II->
getArgOperand(0))->getZExtValue();
200 return SI->isUnordered();
203 switch (II->getIntrinsicID()) {
205 case Intrinsic::lifetime_end:
209 case Intrinsic::init_trampoline:
213 case Intrinsic::memset:
214 case Intrinsic::memmove:
215 case Intrinsic::memcpy:
222 return CS.getInstruction()->use_empty();
232 if (isa<StoreInst>(I))
236 switch (II->getIntrinsicID()) {
237 default:
return false;
238 case Intrinsic::memset:
239 case Intrinsic::memcpy:
263 return SI->getPointerOperand();
265 return MI->getDest();
268 switch (II->getIntrinsicID()) {
270 case Intrinsic::init_trampoline:
271 return II->getArgOperand(0);
302 int64_t &EarlierOff, int64_t &LaterOff,
335 if (ObjectSize == Later.
Size && ObjectSize >= Earlier.
Size)
365 if (EarlierOff >= LaterOff &&
367 uint64_t(EarlierOff - LaterOff) + Earlier.
Size <= Later.
Size)
376 LaterOff < int64_t(EarlierOff + Earlier.
Size) &&
377 int64_t(LaterOff + Later.
Size) >= EarlierOff) {
380 auto &IM = IOL[DepWrite];
381 DEBUG(
dbgs() <<
"DSE: Partial overwrite: Earlier [" << EarlierOff <<
", " <<
382 int64_t(EarlierOff + Earlier.
Size) <<
") Later [" <<
383 LaterOff <<
", " << int64_t(LaterOff + Later.
Size) <<
")\n");
389 int64_t LaterIntStart = LaterOff, LaterIntEnd = LaterOff + Later.
Size;
393 auto ILI = IM.lower_bound(LaterIntStart);
394 if (ILI != IM.end() && ILI->second <= LaterIntEnd) {
398 LaterIntStart =
std::min(LaterIntStart, ILI->second);
399 LaterIntEnd =
std::max(LaterIntEnd, ILI->first);
408 while (ILI != IM.end() && ILI->second <= LaterIntEnd) {
409 assert(ILI->second > LaterIntStart &&
"Unexpected interval");
410 LaterIntEnd =
std::max(LaterIntEnd, ILI->first);
415 IM[LaterIntEnd] = LaterIntStart;
418 if (ILI->second <= EarlierOff &&
419 ILI->first >= int64_t(EarlierOff + Earlier.
Size)) {
420 DEBUG(
dbgs() <<
"DSE: Full overwrite from partials: Earlier [" <<
421 EarlierOff <<
", " <<
422 int64_t(EarlierOff + Earlier.
Size) <<
423 ") Composite Later [" <<
424 ILI->second <<
", " << ILI->first <<
")\n");
425 ++NumCompletePartials;
439 (LaterOff > EarlierOff && LaterOff < int64_t(EarlierOff + Earlier.
Size) &&
440 int64_t(LaterOff + Later.
Size) >= int64_t(EarlierOff + Earlier.
Size)))
453 (LaterOff <= EarlierOff && int64_t(LaterOff + Later.
Size) > EarlierOff)) {
455 int64_t(EarlierOff + Earlier.
Size) &&
456 "Expect to be handled as OW_Complete");
484 if (!InstReadLoc.
Ptr)
return false;
487 if (AA.
isNoAlias(InstReadLoc, InstStoreLoc))
return false;
525 bool isFirstBlock =
true;
528 while (!WorkList.
empty()) {
537 assert(B == SecondBB &&
"first block is not the store block");
539 isFirstBlock =
false;
545 for (; BI != EI; ++BI) {
555 "Should not hit the entry block because SI must be dominated by LI");
557 if (!Visited.
insert(*PredI).second)
572 if (Pred == BB)
continue;
589 bool MadeChange =
false;
596 while (!Blocks.empty()) {
615 DEBUG(
dbgs() <<
"DSE: Dead Store to soon to be freed memory:\n DEAD: "
616 << *Dependency <<
'\n');
649 if (isa<Constant>(UnderlyingPointer))
654 if (isa<AllocaInst>(UnderlyingPointer) || isa<Argument>(UnderlyingPointer)) {
655 DeadStackObjects.
remove(const_cast<Value*>(UnderlyingPointer));
663 return !AA->
isNoAlias(StackLoc, LoadedLoc);
678 bool MadeChange =
false;
687 if (isa<AllocaInst>(&
I))
699 if (AI.hasByValOrInAllocaAttr())
700 DeadStackObjects.
insert(&AI);
716 for (
Value *Pointer : Pointers)
717 if (!DeadStackObjects.
count(Pointer)) {
725 DEBUG(
dbgs() <<
"DSE: Dead Store at End of Block:\n DEAD: "
726 << *Dead <<
"\n Objects: ";
728 E = Pointers.end();
I !=
E; ++
I) {
730 if (std::next(
I) !=
E)
745 DEBUG(
dbgs() <<
"DSE: Removing trivially dead instruction:\n DEAD: "
753 if (isa<AllocaInst>(BBI)) {
756 DeadStackObjects.
remove(&*BBI);
764 DeadStackObjects.
remove(&*BBI);
782 if (DeadStackObjects.
empty())
793 if (isa<FenceInst>(*BBI))
799 if (
LoadInst *
L = dyn_cast<LoadInst>(BBI)) {
800 if (!
L->isUnordered())
803 }
else if (
VAArgInst *V = dyn_cast<VAArgInst>(BBI)) {
807 }
else if (!BBI->mayReadFromMemory()) {
822 if (DeadStackObjects.
empty())
830 int64_t &EarlierSize, int64_t LaterOffset,
831 int64_t LaterSize,
bool IsOverwriteEnd) {
838 MemIntrinsic *EarlierIntrinsic = cast<MemIntrinsic>(EarlierWrite);
839 unsigned EarlierWriteAlign = EarlierIntrinsic->
getAlignment();
841 LaterOffset = int64_t(LaterOffset + LaterSize);
844 !((EarlierWriteAlign != 0) && LaterOffset % EarlierWriteAlign == 0))
847 DEBUG(
dbgs() <<
"DSE: Remove Dead Store:\n OW "
848 << (IsOverwriteEnd ?
"END" :
"BEGIN") <<
": " << *EarlierWrite
849 <<
"\n KILLER (offset " << LaterOffset <<
", " << EarlierSize
852 int64_t NewLength = IsOverwriteEnd
853 ? LaterOffset - EarlierOffset
854 : EarlierSize - (LaterOffset - EarlierOffset);
857 Value *TrimmedLength =
859 EarlierIntrinsic->
setLength(TrimmedLength);
861 EarlierSize = NewLength;
862 if (!IsOverwriteEnd) {
863 int64_t OffsetMoved = (LaterOffset - EarlierOffset);
864 Value *Indices[1] = {
867 EarlierIntrinsic->
getRawDest(), Indices,
"", EarlierWrite);
868 EarlierIntrinsic->
setDest(NewDestGEP);
869 EarlierOffset = EarlierOffset + OffsetMoved;
876 int64_t &EarlierStart, int64_t &EarlierSize) {
880 OverlapIntervalsTy::iterator OII = --IntervalMap.end();
881 int64_t LaterStart = OII->second;
882 int64_t LaterSize = OII->first - LaterStart;
884 if (LaterStart > EarlierStart && LaterStart < EarlierStart + EarlierSize &&
885 LaterStart + LaterSize >= EarlierStart + EarlierSize) {
886 if (
tryToShorten(EarlierWrite, EarlierStart, EarlierSize, LaterStart,
888 IntervalMap.erase(OII);
897 int64_t &EarlierStart, int64_t &EarlierSize) {
901 OverlapIntervalsTy::iterator OII = IntervalMap.begin();
902 int64_t LaterStart = OII->second;
903 int64_t LaterSize = OII->first - LaterStart;
905 if (LaterStart <= EarlierStart && LaterStart + LaterSize > EarlierStart) {
906 assert(LaterStart + LaterSize < EarlierStart + EarlierSize &&
907 "Should have been handled as OW_Complete");
908 if (
tryToShorten(EarlierWrite, EarlierStart, EarlierSize, LaterStart,
910 IntervalMap.erase(OII);
920 bool Changed =
false;
921 for (
auto OI : IOL) {
928 int64_t EarlierStart = 0;
929 int64_t EarlierSize = int64_t(Loc.
Size);
934 if (IntervalMap.empty())
959 DEBUG(
dbgs() <<
"DSE: Remove Store Of Load from same pointer:\n LOAD: "
960 << *DepLoad <<
"\n STORE: " << *SI <<
'\n');
963 ++NumRedundantStores;
974 if (UnderlyingPointer &&
isCallocLikeFn(UnderlyingPointer, TLI) &&
977 dbgs() <<
"DSE: Remove null store to the calloc'ed object:\n DEAD: "
978 << *Inst <<
"\n OBJECT: " << *UnderlyingPointer <<
'\n');
981 ++NumRedundantStores;
992 bool MadeChange =
false;
996 size_t LastThrowingInstIndex = 0;
998 size_t InstrIndex = 1;
1007 MadeChange |=
handleFree(
F, AA, MD, DT, TLI, IOL, &InstrOrdering);
1016 size_t CurInstNumber = InstrIndex++;
1017 InstrOrdering.
insert(std::make_pair(Inst, CurInstNumber));
1019 LastThrowingInstIndex = CurInstNumber;
1077 size_t DepIndex = InstrOrdering.
lookup(DepWrite);
1078 assert(DepIndex &&
"Unexpected instruction");
1079 if (DepIndex <= LastThrowingInstIndex) {
1081 bool IsStoreDeadOnUnwind = isa<AllocaInst>(
Underlying);
1082 if (!IsStoreDeadOnUnwind) {
1090 if (!IsStoreDeadOnUnwind)
1099 int64_t InstWriteOffset, DepWriteOffset;
1101 isOverwrite(Loc, DepLoc, DL, *TLI, DepWriteOffset, InstWriteOffset,
1103 if (OR == OW_Complete) {
1104 DEBUG(
dbgs() <<
"DSE: Remove Dead Store:\n DEAD: "
1105 << *DepWrite <<
"\n KILLER: " << *Inst <<
'\n');
1119 "when partial-overwrite "
1120 "tracking is enabled");
1121 int64_t EarlierSize = DepLoc.
Size;
1122 int64_t LaterSize = Loc.
Size;
1123 bool IsOverwriteEnd = (OR == OW_End);
1124 MadeChange |=
tryToShorten(DepWrite, DepWriteOffset, EarlierSize,
1125 InstWriteOffset, LaterSize, IsOverwriteEnd);
1137 if (DepWrite == &BB.
front())
break;
1155 MadeChange |=
handleEndBlock(BB, AA, MD, TLI, IOL, &InstrOrdering);
1163 bool MadeChange =
false;
1200 bool runOnFunction(
Function &
F)
override {
1201 if (skipFunction(F))
1204 DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1205 AliasAnalysis *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
1207 &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
1209 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
1241 return new DSELegacyPass();
unsigned getAlignment() const
Legacy wrapper pass to provide the GlobalsAAResult object.
bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout &DL, const TargetLibraryInfo *TLI, ObjectSizeOpts Opts={})
Compute the size of the object pointed by Ptr.
Value * getValueOperand()
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Provides a lazy, caching interface for making common memory aliasing information queries, backed by LLVM's alias analysis passes.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static MemoryLocation getLocForWrite(Instruction *Inst, AliasAnalysis &AA)
Return a Location stored to by the specified instruction.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents an incoming formal argument to a Function.
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
STATISTIC(NumFunctions,"Total number of functions")
This is the interface for a simple mod/ref and alias analysis over globals.
std::map< int64_t, int64_t > OverlapIntervalsTy
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
void initializeDSELegacyPassPass(PassRegistry &)
unsigned getNumOperands() const
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias. ...
This class represents a function call, abstracting a target machine's calling convention.
const Function * getParent() const
Return the enclosing method, or null if none.
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
const Instruction & front() const
Analysis pass which computes a DominatorTree.
static bool handleFree(CallInst *F, AliasAnalysis *AA, MemoryDependenceResults *MD, DominatorTree *DT, const TargetLibraryInfo *TLI, InstOverlapIntervalsTy &IOL, DenseMap< Instruction *, size_t > *InstrOrdering)
Handle frees of entire structures whose dependency is a store to a field of that structure.
An instruction for reading from memory.
void GetUnderlyingObjects(Value *V, SmallVectorImpl< Value * > &Objects, const DataLayout &DL, LoopInfo *LI=nullptr, unsigned MaxLookup=6)
This method is similar to GetUnderlyingObject except that it can look through phi and select instruct...
static bool isPossibleSelfRead(Instruction *Inst, const MemoryLocation &InstStoreLoc, Instruction *DepWrite, const TargetLibraryInfo &TLI, AliasAnalysis &AA)
If 'Inst' might be a self read (i.e.
void setDest(Value *Ptr)
Set the specified arguments of the instruction.
The access modifies the value stored in memory.
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
const CallInst * isFreeCall(const Value *I, const TargetLibraryInfo *TLI)
isFreeCall - Returns non-null if the value is a call to the builtin free()
INITIALIZE_PASS_BEGIN(DSELegacyPass,"dse","Dead Store Elimination", false, false) INITIALIZE_PASS_END(DSELegacyPass
iterator begin()
Instruction iterator methods.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
static void findUnconditionalPreds(SmallVectorImpl< BasicBlock * > &Blocks, BasicBlock *BB, DominatorTree *DT)
Find all blocks that will unconditionally lead to the block BB and append them to F...
static OverwriteResult isOverwrite(const MemoryLocation &Later, const MemoryLocation &Earlier, const DataLayout &DL, const TargetLibraryInfo &TLI, int64_t &EarlierOff, int64_t &LaterOff, Instruction *DepWrite, InstOverlapIntervalsTy &IOL)
Return 'OW_Complete' if a store to the 'Later' location completely overwrites a store to the 'Earlier...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr it the function does no...
static bool handleEndBlock(BasicBlock &BB, AliasAnalysis *AA, MemoryDependenceResults *MD, const TargetLibraryInfo *TLI, InstOverlapIntervalsTy &IOL, DenseMap< Instruction *, size_t > *InstrOrdering)
Remove dead stores to stack-allocated locations in the function end block.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
An analysis that produces MemoryDependenceResults for a function.
The access references the value stored in memory.
bool remove(const value_type &X)
Remove an item from the set vector.
LLVM_NODISCARD bool empty() const
static void removeAccessedObjects(const MemoryLocation &LoadedLoc, SmallSetVector< Value *, 16 > &DeadStackObjects, const DataLayout &DL, AliasAnalysis *AA, const TargetLibraryInfo *TLI)
Check to see if the specified location may alias any of the stack objects in the DeadStackObjects set...
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
bool insert(const value_type &X)
Insert a new element into the SetVector.
static Value * getStoredPointerOperand(Instruction *I)
Return the pointer that is being written to.
static MemoryLocation getForDest(const MemIntrinsic *MI)
Return a location representing the destination of a memory set or transfer.
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset...
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
bool empty() const
Determine if the SetVector is empty or not.
An instruction for storing to memory.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
initializer< Ty > init(const Ty &Val)
bool erase(const KeyT &Val)
static bool isShortenableAtTheBeginning(Instruction *I)
Returns true if the beginning of this instruction can be safely shortened in length.
Subclasses of this class are all able to terminate a basic block.
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
static bool removePartiallyOverlappedStores(AliasAnalysis *AA, const DataLayout &DL, InstOverlapIntervalsTy &IOL)
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DenseMap< Instruction *, OverlapIntervalsTy > InstOverlapIntervalsTy
A manager for alias analyses.
static ManagedStatic< OptionRegistry > OR
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static bool hasMemoryWrite(Instruction *I, const TargetLibraryInfo &TLI)
Does this instruction write some memory? This only returns true for things that we can analyze with o...
Value * getRawDest() const
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
static bool isShortenableAtTheEnd(Instruction *I)
Returns true if the end of this instruction can be safely shortened in length.
Represent the analysis usage information of a pass.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
FunctionPass * createDeadStoreEliminationPass()
static bool memoryIsNotModifiedBetween(Instruction *FirstI, Instruction *SecondI, AliasAnalysis *AA)
Returns true if the memory which is accessed by the second instruction is not modified between the fi...
std::underlying_type< E >::type Underlying(E Val)
Check that Val is in range for E, and return Val cast to E's underlying type.
Analysis pass providing a never-invalidated alias analysis result.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
Interval::pred_iterator pred_end(Interval *I)
self_iterator getIterator()
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures, bool StoreCaptures)
PointerMayBeCaptured - Return true if this pointer value may be captured by the enclosing function (w...
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
Value * GetUnderlyingObject(Value *V, const DataLayout &DL, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value...
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
A memory dependence query can return one of three different answers.
unsigned getDefaultBlockScanLimit() const
Some methods limit the number of instructions they will examine.
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
static cl::opt< bool > EnablePartialOverwriteTracking("enable-dse-partial-overwrite-tracking", cl::init(true), cl::Hidden, cl::desc("Enable partial-overwrite tracking in DSE"))
MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst=nullptr, unsigned *Limit=nullptr)
Returns the instruction on which a memory location depends.
static void deleteDeadInstruction(Instruction *I, BasicBlock::iterator *BBI, MemoryDependenceResults &MD, const TargetLibraryInfo &TLI, InstOverlapIntervalsTy &IOL, DenseMap< Instruction *, size_t > *InstrOrdering, SmallSetVector< Value *, 16 > *ValueSet=nullptr)
Delete this instruction.
A SetVector that performs no allocations if smaller than a certain size.
bool doesNotAccessMemory(ImmutableCallSite CS)
Checks if the specified call is known to never read or write memory.
This is the common base class for memset/memcpy/memmove.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
ValTy * getArgument(unsigned ArgNo) const
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
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.
Value * getLength() const
LLVM_NODISCARD T pop_back_val()
bool isNonLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the block...
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
const BasicBlock & getEntryBlock() const
static bool eliminateNoopStore(Instruction *Inst, BasicBlock::iterator &BBI, AliasAnalysis *AA, MemoryDependenceResults *MD, const DataLayout &DL, const TargetLibraryInfo *TLI, InstOverlapIntervalsTy &IOL, DenseMap< Instruction *, size_t > *InstrOrdering)
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
void setOperand(unsigned i, Value *Val)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are must-alias.
Represents analyses that only rely on functions' control flow.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
bool mayThrow() const
Return true if this instruction may throw an exception.
This class wraps the llvm.memcpy/memmove intrinsics.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Instruction * getInst() const
If this is a normal dependency, returns the instruction that is depended on.
static bool tryToShortenBegin(Instruction *EarlierWrite, OverlapIntervalsTy &IntervalMap, int64_t &EarlierStart, int64_t &EarlierSize)
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
static MemoryLocation getLocForRead(Instruction *Inst, const TargetLibraryInfo &TLI)
Return the location read by the specified "hasMemoryWrite" instruction if any.
void preserveSet()
Mark an analysis set as preserved.
bool isCallocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates zero-filled memory (such as...
The access both references and modifies the value stored in memory.
bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates memory (either malloc...
StringRef getName(LibFunc F) const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void preserve()
Mark an analysis as preserved.
Analysis pass providing the TargetLibraryInfo.
static bool eliminateDeadStores(BasicBlock &BB, AliasAnalysis *AA, MemoryDependenceResults *MD, DominatorTree *DT, const TargetLibraryInfo *TLI)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction has no side ef...
LLVM Value Representation.
void removeInstruction(Instruction *InstToRemove)
Removes an instruction from the dependence analysis, updating the dependence of instructions that pre...
bool remove_if(UnaryPredicate P)
Remove items from the set vector based on a predicate function.
static bool isRemovable(Instruction *I)
If the value of this instruction and the memory it writes to is unused, may we delete this instructio...
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
static bool isVolatile(Instruction *Inst)
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static uint64_t getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI)
Value * getPointerOperand()
const BasicBlock * getParent() const
static bool tryToShorten(Instruction *EarlierWrite, int64_t &EarlierOffset, int64_t &EarlierSize, int64_t LaterOffset, int64_t LaterSize, bool IsOverwriteEnd)
bool has(LibFunc F) const
Tests whether a library function is available.
iterator_range< arg_iterator > args()
A wrapper class for inspecting calls to intrinsic functions.
static bool tryToShortenEnd(Instruction *EarlierWrite, OverlapIntervalsTy &IntervalMap, int64_t &EarlierStart, int64_t &EarlierSize)
uint64_t Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known...
MemDepResult getDependency(Instruction *QueryInst)
Returns the instruction on which a memory operation depends.
static MemoryLocation getForSource(const MemTransferInst *MTI)
Return a location representing the source of a memory transfer.