66 #define DEBUG_TYPE "memcpyopt" 68 STATISTIC(NumMemCpyInstr,
"Number of memcpy instructions deleted");
69 STATISTIC(NumMemSetInfer,
"Number of memsets inferred");
70 STATISTIC(NumMoveToCpy,
"Number of memmoves converted to memcpy");
71 STATISTIC(NumCpyToSet,
"Number of memcpys converted to memset");
74 bool &VariableIdxFound,
78 for (
unsigned i = 1; i != Idx; ++i, ++GTI)
83 for (
unsigned i = Idx, e = GEP->
getNumOperands(); i != e; ++i, ++GTI) {
86 return VariableIdxFound =
true;
87 if (OpC->
isZero())
continue;
121 bool VariableIdxFound =
false;
127 return !VariableIdxFound;
132 return !VariableIdxFound;
140 if (!GEP1 || !GEP2 || GEP1->
getOperand(0) != GEP2->getOperand(0))
145 for (; Idx != GEP1->
getNumOperands() && Idx != GEP2->getNumOperands(); ++Idx)
146 if (GEP1->
getOperand(Idx) != GEP2->getOperand(Idx))
151 if (VariableIdxFound)
return false;
153 Offset = Offset2-Offset1;
184 bool isProfitableToUseMemset(
const DataLayout &DL)
const;
189 bool MemsetRange::isProfitableToUseMemset(
const DataLayout &DL)
const {
191 if (TheStores.size() >= 4 || End-Start >= 16)
return true;
194 if (TheStores.size() < 2)
return false;
199 if (!isa<StoreInst>(
SI))
204 if (TheStores.size() == 2)
return false;
216 unsigned Bytes =
unsigned(End-Start);
220 unsigned NumPointerStores = Bytes / MaxIntSize;
223 unsigned NumByteStores = Bytes % MaxIntSize;
228 return TheStores.size() > NumPointerStores+NumByteStores;
242 MemsetRanges(
const DataLayout &DL) : DL(DL) {}
246 const_iterator
begin()
const {
return Ranges.
begin(); }
247 const_iterator
end()
const {
return Ranges.
end(); }
250 void addInst(int64_t OffsetFromFirst,
Instruction *Inst) {
252 addStore(OffsetFromFirst,
SI);
254 addMemSet(OffsetFromFirst, cast<MemSetInst>(Inst));
257 void addStore(int64_t OffsetFromFirst,
StoreInst *
SI) {
260 addRange(OffsetFromFirst, StoreSize,
264 void addMemSet(int64_t OffsetFromFirst,
MemSetInst *MSI) {
265 int64_t
Size = cast<ConstantInt>(MSI->
getLength())->getZExtValue();
280 int64_t End = Start+
Size;
283 [](
const MemsetRange &LHS, int64_t RHS) {
return LHS.End < RHS; });
288 if (I == Ranges.end() || End < I->Start) {
289 MemsetRange &R = *Ranges.insert(I, MemsetRange());
293 R.Alignment = Alignment;
294 R.TheStores.push_back(Inst);
299 I->TheStores.push_back(Inst);
303 if (I->Start <= Start && I->End >= End)
312 if (Start < I->Start) {
315 I->Alignment = Alignment;
323 range_iterator NextI =
I;
324 while (++NextI != Ranges.end() && End >= NextI->Start) {
326 I->TheStores.append(NextI->TheStores.begin(), NextI->TheStores.end());
327 if (NextI->End > I->End)
392 const DataLayout &DL = StartInst->getModule()->getDataLayout();
398 MemsetRanges Ranges(DL);
401 for (++BI; !BI->isTerminator(); ++BI) {
402 if (!isa<StoreInst>(BI) && !isa<MemSetInst>(BI)) {
406 if (BI->mayWriteToMemory() || BI->mayReadFromMemory())
411 if (
StoreInst *NextStore = dyn_cast<StoreInst>(BI)) {
413 if (!NextStore->isSimple())
break;
417 if (isa<UndefValue>(ByteVal) && StoredByte)
418 ByteVal = StoredByte;
419 if (ByteVal != StoredByte)
428 Ranges.addStore(Offset, NextStore);
441 Ranges.addMemSet(Offset, MSI);
453 Ranges.addInst(0, StartInst);
463 for (
const MemsetRange &Range : Ranges) {
464 if (Range.TheStores.size() == 1)
continue;
467 if (!Range.isProfitableToUseMemset(DL))
472 StartPtr = Range.StartPtr;
475 unsigned Alignment = Range.Alignment;
476 if (Alignment == 0) {
478 cast<PointerType>(StartPtr->getType())->getElementType();
483 Builder.
CreateMemSet(StartPtr, ByteVal, Range.End-Range.Start, Alignment);
486 : Range.TheStores)
dbgs()
488 dbgs() <<
"With: " << *AMemSet <<
'\n');
490 if (!Range.TheStores.empty())
491 AMemSet->
setDebugLoc(Range.TheStores[0]->getDebugLoc());
495 MD->removeInstruction(SI);
522 return MinAlign(StoreAlign, LoadAlign);
559 bool NeedLift =
false;
581 else if (
const auto *Call = dyn_cast<CallBase>(
C)) {
587 }
else if (isa<LoadInst>(
C) || isa<StoreInst>(
C) || isa<VAArgInst>(
C)) {
593 MemLocs.push_back(ML);
601 if (
auto *A = dyn_cast<Instruction>(
C->
getOperand(k)))
631 if (LI->isSimple() && LI->hasOneUse() &&
634 auto *
T = LI->getType();
635 if (
T->isAggregateType()) {
656 if (!
moveUp(AA, SI, P, LI))
666 bool UseMemMove =
false;
683 LLVM_DEBUG(
dbgs() <<
"Promoting " << *LI <<
" to " << *SI <<
" => " 686 MD->removeInstruction(SI);
688 MD->removeInstruction(LI);
689 LI->eraseFromParent();
710 bool CpyDestIsLocal = isa<AllocaInst>(CpyDest);
721 if (
I->mayThrow() && !CpyDestIsLocal) {
729 bool changed = performCallSlotOptzn(
735 MD->removeInstruction(SI);
737 MD->removeInstruction(LI);
738 LI->eraseFromParent();
756 BBI =
I->getIterator();
763 auto *
T = V->getType();
764 if (
T->isAggregateType()) {
773 LLVM_DEBUG(
dbgs() <<
"Promoting " << *SI <<
" to " << *M <<
"\n");
775 MD->removeInstruction(SI);
780 BBI = M->getIterator();
794 BBI =
I->getIterator();
804 Value *cpySrc, uint64_t cpyLen,
842 if (cpyLen < srcSize)
848 if (
AllocaInst *A = dyn_cast<AllocaInst>(cpyDest)) {
857 if (destSize < srcSize)
859 }
else if (
Argument *A = dyn_cast<Argument>(cpyDest)) {
864 if (A->getDereferenceableBytes() < srcSize) {
867 if (!A->hasStructRetAttr())
870 Type *StructTy = cast<PointerType>(A->getType())->getElementType();
879 if (destSize < srcSize)
890 bool isDestSufficientlyAligned = srcAlign <= cpyAlign;
893 if (!isDestSufficientlyAligned && !isa<AllocaInst>(cpyDest))
902 while (!srcUseList.empty()) {
903 User *U = srcUseList.pop_back_val();
905 if (isa<BitCastInst>(U) || isa<AddrSpaceCastInst>(U)) {
907 srcUseList.push_back(UU);
911 if (!
G->hasAllZeroIndices())
915 srcUseList.push_back(UU);
919 if (
IT->isLifetimeStartOrEnd())
922 if (U != C && U != cpy)
928 for (
unsigned i = 0, e = CS.
arg_size(); i != e; ++i)
935 if (
Instruction *cpyDestInst = dyn_cast<Instruction>(cpyDest))
956 for (
unsigned i = 0; i < CS.
arg_size(); ++i)
963 bool changedArgument =
false;
964 for (
unsigned i = 0; i < CS.
arg_size(); ++i)
969 changedArgument =
true;
977 if (!changedArgument)
981 if (!isDestSufficientlyAligned) {
982 assert(isa<AllocaInst>(cpyDest) &&
"Can only increase alloca alignment!");
983 cast<AllocaInst>(cpyDest)->setAlignment(srcAlign);
988 MD->removeInstruction(C);
1000 MD->removeInstruction(cpy);
1008 bool MemCpyOptPass::processMemCpyMemCpyDependence(
MemCpyInst *M,
1027 if (!MDepLen || !MLen || MDepLen->
getZExtValue() < MLen->getZExtValue())
1053 bool UseMemMove =
false;
1059 LLVM_DEBUG(
dbgs() <<
"MemCpyOptPass: Forwarding memcpy->memcpy src:\n" 1060 << *MDep <<
'\n' << *M <<
'\n');
1075 MD->removeInstruction(M);
1095 bool MemCpyOptPass::processMemSetMemCpyDependence(
MemCpyInst *MemCpy,
1105 if (DstDepInfo.
getInst() != MemSet)
1117 const unsigned DestAlign =
1120 if (
ConstantInt *SrcSizeC = dyn_cast<ConstantInt>(SrcSize))
1121 Align =
MinAlign(SrcSizeC->getZExtValue(), DestAlign);
1141 MD->removeInstruction(MemSet);
1149 if (isa<AllocaInst>(I))
1154 if (
ConstantInt *LTSize = dyn_cast<ConstantInt>(II->getArgOperand(0)))
1175 bool MemCpyOptPass::performMemCpyToMemSetOptzn(
MemCpyInst *MemCpy,
1201 CopySize = MemSetSize;
1217 bool MemCpyOptPass::processMemCpy(
MemCpyInst *M) {
1223 MD->removeInstruction(M);
1230 if (GV->isConstant() && GV->hasDefinitiveInitializer())
1235 MD->removeInstruction(M);
1247 if (processMemSetMemCpyDependence(M, MDep))
1252 if (!CopySize)
return false;
1269 MD->removeInstruction(M);
1277 MemDepResult SrcDepInfo = MD->getPointerDependencyFrom(
1282 return processMemCpyMemCpyDependence(M, MDep);
1283 }
else if (SrcDepInfo.
isDef()) {
1285 MD->removeInstruction(M);
1294 if (performMemCpyToMemSetOptzn(M, MDep)) {
1295 MD->removeInstruction(M);
1306 bool MemCpyOptPass::processMemMove(
MemMoveInst *M) {
1309 if (!TLI->has(LibFunc_memmove))
1317 LLVM_DEBUG(
dbgs() <<
"MemCpyOptPass: Optimizing memmove -> memcpy: " << *M
1329 MD->removeInstruction(M);
1336 bool MemCpyOptPass::processByValArgument(
CallSite CS,
unsigned ArgNo) {
1340 Type *ByValTy = cast<PointerType>(ByValArg->
getType())->getElementType();
1364 if (ByValAlign == 0)
return false;
1400 LLVM_DEBUG(
dbgs() <<
"MemCpyOptPass: Forwarding memcpy to byval:\n" 1401 <<
" " << *MDep <<
"\n" 1411 bool MemCpyOptPass::iterateOnFunction(
Function &
F) {
1412 bool MadeChange =
false;
1429 bool RepeatInstruction =
false;
1431 if (
StoreInst *SI = dyn_cast<StoreInst>(I))
1432 MadeChange |= processStore(SI, BI);
1433 else if (
MemSetInst *M = dyn_cast<MemSetInst>(I))
1434 RepeatInstruction = processMemSet(M, BI);
1435 else if (
MemCpyInst *M = dyn_cast<MemCpyInst>(I))
1436 RepeatInstruction = processMemCpy(M);
1437 else if (
MemMoveInst *M = dyn_cast<MemMoveInst>(I))
1438 RepeatInstruction = processMemMove(M);
1440 for (
unsigned i = 0, e = CS.
arg_size(); i != e; ++i)
1442 MadeChange |= processByValArgument(CS, i);
1446 if (RepeatInstruction) {
1447 if (BI != BB.begin())
1471 bool MadeChange =
runImpl(F, &MD, &TLI, LookupAliasAnalysis,
1472 LookupAssumptionCache, LookupDomTree);
1488 bool MadeChange =
false;
1491 LookupAliasAnalysis = std::move(LookupAliasAnalysis_);
1492 LookupAssumptionCache = std::move(LookupAssumptionCache_);
1493 LookupDomTree = std::move(LookupDomTree_);
1498 if (!TLI->has(LibFunc_memset) || !TLI->has(LibFunc_memcpy))
1502 if (!iterateOnFunction(F))
1513 if (skipFunction(F))
1516 auto *MD = &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
1517 auto *TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
1520 return getAnalysis<AAResultsWrapperPass>().getAAResults();
1523 return getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
1526 return getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1529 return Impl.runImpl(F, MD, TLI, LookupAliasAnalysis, LookupAssumptionCache,
Legacy wrapper pass to provide the GlobalsAAResult object.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
A parsed version of the target data layout string in and methods for querying it. ...
const_iterator end(StringRef path)
Get end iterator over path.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static bool runImpl(Function &F, TargetLibraryInfo &TLI, DominatorTree &DT)
This is the entry point for all transforms.
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.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
uint64_t getZExtValue() const
Get zero extended value.
unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to ensure that the alignment of V is at least PrefAlign bytes.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents an incoming formal argument to a Function.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
unsigned arg_size() const
typename SuperClass::const_iterator const_iterator
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Value * isBytewiseValue(Value *V)
If the specified value can be set by repeating the same byte in memory, return the i8 value that it i...
INITIALIZE_PASS_BEGIN(MemCpyOptLegacyPass, "memcpyopt", "MemCpy Optimization", false, false) INITIALIZE_PASS_END(MemCpyOptLegacyPass
This is the interface for a simple mod/ref and alias analysis over globals.
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Implements a dense probed hash-table based set.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
void push_back(const T &Elt)
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias. ...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
This class represents a function call, abstracting a target machine's calling convention.
An immutable pass that tracks lazily created AssumptionCache objects.
unsigned getSourceAlignment() const
A cache of @llvm.assume calls within a function.
static LocationSize precise(uint64_t Value)
bool erase(const ValueT &V)
static bool IsPointerOffset(Value *Ptr1, Value *Ptr2, int64_t &Offset, const DataLayout &DL)
Return true if Ptr1 is provably equal to Ptr2 plus a constant offset, and return that constant offset...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This class wraps the llvm.memset intrinsic.
STATISTIC(NumFunctions, "Total number of functions")
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Analysis pass which computes a DominatorTree.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memset to the specified pointer and the specified value.
An instruction for reading from memory.
Value * CreateICmpULE(Value *LHS, Value *RHS, const Twine &Name="")
Value * getLength() const
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions (including addrspacecast) that ...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
static int64_t GetOffsetFromIndex(const GEPOperator *GEP, unsigned Idx, bool &VariableIdxFound, const DataLayout &DL)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
static unsigned findStoreAlignment(const DataLayout &DL, const StoreInst *SI)
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
This class wraps the llvm.memmove intrinsic.
Class to represent struct types.
static bool hasUndefContents(Instruction *I, ConstantInt *Size)
Determine whether the instruction has undefined content for the given Size, either because it was fre...
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
void setCalledFunction(Value *Fn)
Sets the function called, including updating the function type.
InstrTy * getInstruction() const
An analysis that produces MemoryDependenceResults for a function.
CallInst * CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memmove between the specified pointers.
unsigned getDestAlignment() const
void setArgument(unsigned ArgNo, Value *newVal)
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
Type * getType() const
All values are typed, get the type of this value.
static MemoryLocation getForDest(const MemIntrinsic *MI)
Return a location representing the destination of a memory set or transfer.
This class represents a no-op cast from one type to another.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
void combineMetadata(Instruction *K, const Instruction *J, ArrayRef< unsigned > KnownIDs, bool DoesKMove)
Combine the metadata of two instructions so that K can replace J.
const APInt & getValue() const
Return the constant as an APInt value reference.
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
An instruction for storing to memory.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Value * getOperand(unsigned i) const
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
static bool runOnFunction(Function &F, bool PostInlining)
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
A set of analyses that are preserved following a run of a transformation pass.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
A manager for alias analyses.
std::pair< iterator, bool > insert(const ValueT &V)
bool mayThrow() const
Return true if this instruction may throw an exception.
Represent the analysis usage information of a pass.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Analysis pass providing a never-invalidated alias analysis result.
unsigned getLargestLegalIntTypeSizeInBits() const
Returns the size of largest legal integer type size, or 0 if none are set.
FunctionPass * createMemCpyOptPass()
The public interface to this file...
FunctionPass class - This class is used to implement most global optimizations.
self_iterator getIterator()
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
Type * getIndexedType() const
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void initializeMemCpyOptLegacyPassPass(PassRegistry &)
const Value * getArraySize() const
Get the number of elements allocated.
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
A memory dependence query can return one of three different answers.
bool runImpl(Function &F, MemoryDependenceResults *MD_, TargetLibraryInfo *TLI_, std::function< AliasAnalysis &()> LookupAliasAnalysis_, std::function< AssumptionCache &()> LookupAssumptionCache_, std::function< DominatorTree &()> LookupDomTree_)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
The two locations may or may not alias. This is the least precise result.
Value * CreateGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Representation for a specific memory location.
A function analysis which provides an AssumptionCache.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Iterator for intrusive lists based on ilist_node.
StructType * getStructTypeOrNull() const
unsigned getNumOperands() const
This is the shared class of boolean and integer constants.
ValTy * getArgument(unsigned ArgNo) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
Module.h This file contains the declarations for the Module class.
Provides information about what library functions are available for the current target.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
static unsigned findLoadAlignment(const DataLayout &DL, const LoadInst *LI)
CallInst * CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memcpy between the specified pointers.
This class wraps the llvm.memcpy intrinsic.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Value * getRawSource() const
Return the arguments to the instruction.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
ModRefInfo callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT, OrderedBasicBlock *OBB=nullptr)
Return information about whether a particular call site modifies or reads the specified memory locati...
typename SuperClass::iterator iterator
iterator_range< user_iterator > users()
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.
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::ZeroOrMore, cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate IT block based on arch"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow deprecated IT based on ARMv8"), clEnumValN(NoRestrictedIT, "arm-no-restrict-it", "Allow IT blocks based on ARMv7")))
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
LLVM_NODISCARD bool isModSet(const ModRefInfo MRI)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
FunTy * getCaller() const
Return the caller function for this call site.
uint64_t getElementOffset(unsigned Idx) const
unsigned getAlignment() const
Return the alignment of the access that is being performed.
Instruction * getInst() const
If this is a normal dependency, returns the instruction that is depended on.
unsigned getIntegerBitWidth() const
LLVM_NODISCARD bool empty() const
This file provides utility analysis objects describing memory locations.
void preserveSet()
Mark an analysis set as preserved.
StringRef getName() const
Return a constant reference to the value's name.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
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.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
Analysis pass providing the TargetLibraryInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it...
print Print MemDeps of function
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
LLVM_NODISCARD bool isModOrRefSet(const ModRefInfo MRI)
static bool moveUp(AliasAnalysis &AA, StoreInst *SI, Instruction *P, const LoadInst *LI)
static unsigned findCommonAlignment(const DataLayout &DL, const StoreInst *SI, const LoadInst *LI)
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
This header defines various interfaces for pass management in LLVM.
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
Value * getPointerOperand()
Value * getRawDest() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
A wrapper class for inspecting calls to intrinsic functions.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
gep_type_iterator gep_type_begin(const User *GEP)
static MemoryLocation getForSource(const MemTransferInst *MTI)
Return a location representing the source of a memory transfer.