60 #define DEBUG_TYPE "memcpyopt"
62 STATISTIC(NumMemCpyInstr,
"Number of memcpy instructions deleted");
63 STATISTIC(NumMemSetInfer,
"Number of memsets inferred");
64 STATISTIC(NumMoveToCpy,
"Number of memmoves converted to memcpy");
65 STATISTIC(NumCpyToSet,
"Number of memcpys converted to memset");
68 bool &VariableIdxFound,
72 for (
unsigned i = 1; i != Idx; ++i, ++GTI)
77 for (
unsigned i = Idx, e = GEP->
getNumOperands(); i != e; ++i, ++GTI) {
80 return VariableIdxFound =
true;
81 if (OpC->
isZero())
continue;
115 bool VariableIdxFound =
false;
121 return !VariableIdxFound;
126 return !VariableIdxFound;
134 if (!GEP1 || !GEP2 || GEP1->
getOperand(0) != GEP2->getOperand(0))
139 for (; Idx != GEP1->
getNumOperands() && Idx != GEP2->getNumOperands(); ++Idx)
140 if (GEP1->
getOperand(Idx) != GEP2->getOperand(Idx))
145 if (VariableIdxFound)
return false;
147 Offset = Offset2-Offset1;
178 bool isProfitableToUseMemset(
const DataLayout &
DL)
const;
183 bool MemsetRange::isProfitableToUseMemset(
const DataLayout &
DL)
const {
185 if (TheStores.size() >= 4 ||
End-Start >= 16)
return true;
188 if (TheStores.size() < 2)
return false;
193 if (!isa<StoreInst>(SI))
198 if (TheStores.size() == 2)
return false;
214 unsigned NumPointerStores = Bytes / MaxIntSize;
217 unsigned NumByteStores = Bytes % MaxIntSize;
222 return TheStores.size() > NumPointerStores+NumByteStores;
234 MemsetRanges(
const DataLayout &DL) : DL(DL) {}
237 const_iterator
begin()
const {
return Ranges.
begin(); }
238 const_iterator
end()
const {
return Ranges.
end(); }
239 bool empty()
const {
return Ranges.empty(); }
241 void addInst(int64_t OffsetFromFirst,
Instruction *Inst) {
242 if (
StoreInst *SI = dyn_cast<StoreInst>(Inst))
243 addStore(OffsetFromFirst, SI);
245 addMemSet(OffsetFromFirst, cast<MemSetInst>(Inst));
248 void addStore(int64_t OffsetFromFirst,
StoreInst *SI) {
251 addRange(OffsetFromFirst, StoreSize,
255 void addMemSet(int64_t OffsetFromFirst,
MemSetInst *MSI) {
256 int64_t
Size = cast<ConstantInt>(MSI->
getLength())->getZExtValue();
274 range_iterator
I = std::lower_bound(Ranges.begin(), Ranges.end(), Start,
275 [](
const MemsetRange &LHS, int64_t RHS) {
return LHS.End < RHS; });
280 if (I == Ranges.end() || End < I->Start) {
281 MemsetRange &R = *Ranges.insert(I, MemsetRange());
285 R.Alignment = Alignment;
286 R.TheStores.push_back(Inst);
291 I->TheStores.push_back(Inst);
295 if (I->Start <= Start && I->End >= End)
304 if (Start < I->Start) {
307 I->Alignment = Alignment;
315 range_iterator NextI =
I;
316 while (++NextI != Ranges.end() && End >= NextI->Start) {
318 I->TheStores.append(NextI->TheStores.begin(), NextI->TheStores.end());
319 if (NextI->End > I->End)
343 bool runOnFunction(
Function &
F)
override;
384 const DataLayout &DL = StartInst->getModule()->getDataLayout();
390 MemsetRanges Ranges(DL);
393 for (++BI; !isa<TerminatorInst>(BI); ++BI) {
394 if (!isa<StoreInst>(BI) && !isa<MemSetInst>(BI)) {
398 if (BI->mayWriteToMemory() || BI->mayReadFromMemory())
403 if (
StoreInst *NextStore = dyn_cast<StoreInst>(BI)) {
405 if (!NextStore->isSimple())
break;
417 Ranges.addStore(Offset, NextStore);
430 Ranges.addMemSet(Offset, MSI);
442 Ranges.addInst(0, StartInst);
452 for (
const MemsetRange &Range : Ranges) {
454 if (Range.TheStores.size() == 1)
continue;
457 if (!Range.isProfitableToUseMemset(DL))
462 StartPtr = Range.StartPtr;
465 unsigned Alignment = Range.Alignment;
466 if (Alignment == 0) {
468 cast<PointerType>(StartPtr->getType())->getElementType();
473 Builder.
CreateMemSet(StartPtr, ByteVal, Range.End-Range.Start, Alignment);
477 dbgs() << *SI <<
'\n';
478 dbgs() <<
"With: " << *AMemSet <<
'\n');
480 if (!Range.TheStores.empty())
481 AMemSet->
setDebugLoc(Range.TheStores[0]->getDebugLoc());
485 MD->removeInstruction(SI);
503 return std::min(StoreAlign, LoadAlign);
540 bool NeedLift =
false;
569 }
else if (isa<LoadInst>(
C) || isa<StoreInst>(
C) || isa<VAArgInst>(
C)) {
575 MemLocs.push_back(ML);
582 for (
unsigned k = 0, e =
C->getNumOperands(); k != e; ++k)
583 if (
auto *
A = dyn_cast<Instruction>(
C->getOperand(k)))
590 DEBUG(
dbgs() <<
"Lifting " << *I <<
" before " << *P <<
"\n");
613 if (LI->isSimple() && LI->hasOneUse() &&
616 auto *
T = LI->getType();
617 if (
T->isAggregateType()) {
638 if (!
moveUp(AA, SI, P, LI))
648 bool UseMemMove =
false;
659 LI->getPointerOperand(),
Size,
663 LI->getPointerOperand(),
Size,
666 DEBUG(
dbgs() <<
"Promoting " << *LI <<
" to " << *SI
667 <<
" => " << *M <<
"\n");
672 LI->eraseFromParent();
693 bool CpyDestIsLocal = isa<AllocaInst>(CpyDest);
704 if (I->mayThrow() && !CpyDestIsLocal) {
712 bool changed = performCallSlotOptzn(
721 LI->eraseFromParent();
739 BBI = I->getIterator();
746 auto *
T = V->getType();
747 if (
T->isAggregateType()) {
756 DEBUG(
dbgs() <<
"Promoting " << *SI <<
" to " << *M <<
"\n");
777 BBI = I->getIterator();
787 Value *cpySrc, uint64_t cpyLen,
805 if (
F->isIntrinsic() &&
F->getIntrinsicID() == Intrinsic::lifetime_start)
825 if (cpyLen < srcSize)
831 if (
AllocaInst *
A = dyn_cast<AllocaInst>(cpyDest)) {
840 if (destSize < srcSize)
842 }
else if (
Argument *
A = dyn_cast<Argument>(cpyDest)) {
847 if (
A->getDereferenceableBytes() < srcSize) {
850 if (!
A->hasStructRetAttr())
853 Type *StructTy = cast<PointerType>(
A->getType())->getElementType();
862 if (destSize < srcSize)
873 bool isDestSufficientlyAligned = srcAlign <= cpyAlign;
876 if (!isDestSufficientlyAligned && !isa<AllocaInst>(cpyDest))
885 while (!srcUseList.empty()) {
886 User *U = srcUseList.pop_back_val();
888 if (isa<BitCastInst>(U) || isa<AddrSpaceCastInst>(U)) {
890 srcUseList.push_back(UU);
894 if (!
G->hasAllZeroIndices())
898 srcUseList.push_back(UU);
902 if (
IT->getIntrinsicID() == Intrinsic::lifetime_start ||
903 IT->getIntrinsicID() == Intrinsic::lifetime_end)
906 if (U != C && U != cpy)
912 for (
unsigned i = 0, e =
CS.arg_size(); i != e; ++i)
913 if (
CS.getArgument(i) == cpySrc && !
CS.doesNotCapture(i))
919 if (
Instruction *cpyDestInst = dyn_cast<Instruction>(cpyDest))
940 for (
unsigned i = 0; i <
CS.arg_size(); ++i)
941 if (
CS.getArgument(i)->stripPointerCasts() == cpySrc &&
943 CS.getArgument(i)->getType()->getPointerAddressSpace())
947 bool changedArgument =
false;
948 for (
unsigned i = 0; i <
CS.arg_size(); ++i)
949 if (
CS.getArgument(i)->stripPointerCasts() == cpySrc) {
953 changedArgument =
true;
954 if (
CS.getArgument(i)->getType() == Dest->
getType())
955 CS.setArgument(i, Dest);
958 CS.getArgument(i)->getType(), Dest->
getName(),
C));
961 if (!changedArgument)
965 if (!isDestSufficientlyAligned) {
966 assert(isa<AllocaInst>(cpyDest) &&
"Can only increase alloca alignment!");
967 cast<AllocaInst>(cpyDest)->setAlignment(srcAlign);
991 bool MemCpyOptPass::processMemCpyMemCpyDependence(
MemCpyInst *M,
1010 if (!MDepLen || !MLen || MDepLen->
getZExtValue() < MLen->getZExtValue())
1036 bool UseMemMove =
false;
1079 bool MemCpyOptPass::processMemSetMemCpyDependence(
MemCpyInst *MemCpy,
1089 if (DstDepInfo.
getInst() != MemSet)
1101 const unsigned DestAlign =
1104 if (
ConstantInt *SrcSizeC = dyn_cast<ConstantInt>(SrcSize))
1105 Align =
MinAlign(SrcSizeC->getZExtValue(), DestAlign);
1113 SrcSize = Builder.CreateZExt(SrcSize, DestSize->
getType());
1115 DestSize = Builder.CreateZExt(DestSize, SrcSize->
getType());
1118 Value *Ule = Builder.CreateICmpULE(DestSize, SrcSize);
1119 Value *SizeDiff = Builder.CreateSub(DestSize, SrcSize);
1120 Value *MemsetLen = Builder.CreateSelect(
1122 Builder.CreateMemSet(Builder.CreateGEP(Dest, SrcSize), MemSet->
getOperand(1),
1144 bool MemCpyOptPass::performMemCpyToMemSetOptzn(
MemCpyInst *MemCpy,
1157 if (!MemSetSize || CopySize->
getZExtValue() > MemSetSize->getZExtValue())
1171 bool MemCpyOptPass::processMemCpy(
MemCpyInst *M) {
1184 if (GV->isConstant() && GV->hasDefinitiveInitializer())
1201 if (processMemSetMemCpyDependence(M, MDep))
1206 if (!CopySize)
return false;
1233 return processMemCpyMemCpyDependence(M, MDep);
1234 }
else if (SrcDepInfo.
isDef()) {
1236 bool hasUndefContents =
false;
1238 if (isa<AllocaInst>(I)) {
1239 hasUndefContents =
true;
1240 }
else if (
IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
1241 if (II->getIntrinsicID() == Intrinsic::lifetime_start)
1242 if (
ConstantInt *LTSize = dyn_cast<ConstantInt>(II->getArgOperand(0)))
1243 if (LTSize->getZExtValue() >= CopySize->
getZExtValue())
1244 hasUndefContents =
true;
1247 if (hasUndefContents) {
1257 if (performMemCpyToMemSetOptzn(M, MDep)) {
1269 bool MemCpyOptPass::processMemMove(
MemMoveInst *M) {
1272 if (!TLI->
has(LibFunc_memmove))
1280 DEBUG(
dbgs() <<
"MemCpyOptPass: Optimizing memmove -> memcpy: " << *M
1288 Intrinsic::memcpy, ArgTys));
1299 bool MemCpyOptPass::processByValArgument(
CallSite CS,
unsigned ArgNo) {
1303 Type *ByValTy = cast<PointerType>(ByValArg->
getType())->getElementType();
1327 if (ByValAlign == 0)
return false;
1363 DEBUG(
dbgs() <<
"MemCpyOptPass: Forwarding memcpy to byval:\n"
1364 <<
" " << *MDep <<
"\n"
1374 bool MemCpyOptPass::iterateOnFunction(
Function &
F) {
1375 bool MadeChange =
false;
1383 bool RepeatInstruction =
false;
1385 if (
StoreInst *SI = dyn_cast<StoreInst>(I))
1386 MadeChange |= processStore(SI, BI);
1387 else if (
MemSetInst *M = dyn_cast<MemSetInst>(I))
1388 RepeatInstruction = processMemSet(M, BI);
1389 else if (
MemCpyInst *M = dyn_cast<MemCpyInst>(I))
1390 RepeatInstruction = processMemCpy(M);
1391 else if (
MemMoveInst *M = dyn_cast<MemMoveInst>(I))
1392 RepeatInstruction = processMemMove(M);
1394 for (
unsigned i = 0, e = CS.
arg_size(); i != e; ++i)
1396 MadeChange |= processByValArgument(CS, i);
1400 if (RepeatInstruction) {
1401 if (BI != BB.begin())
1425 bool MadeChange =
runImpl(F, &MD, &TLI, LookupAliasAnalysis,
1426 LookupAssumptionCache, LookupDomTree);
1442 bool MadeChange =
false;
1445 LookupAliasAnalysis = std::move(LookupAliasAnalysis_);
1446 LookupAssumptionCache = std::move(LookupAssumptionCache_);
1447 LookupDomTree = std::move(LookupDomTree_);
1452 if (!TLI->
has(LibFunc_memset) || !TLI->
has(LibFunc_memcpy))
1456 if (!iterateOnFunction(F))
1466 bool MemCpyOptLegacyPass::runOnFunction(
Function &F) {
1467 if (skipFunction(F))
1470 auto *MD = &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
1471 auto *TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
1474 return getAnalysis<AAResultsWrapperPass>().getAAResults();
1477 return getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
1480 return getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1483 return Impl.runImpl(F, MD, TLI, LookupAliasAnalysis, LookupAssumptionCache,
unsigned getAlignment() const
Legacy wrapper pass to provide the GlobalsAAResult object.
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")))
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. ...
Type * getIndexedType() const
const_iterator end(StringRef path)
Get end iterator over path.
FunTy * getCaller() const
Return the caller function for this call site.
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...
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.
uint64_t getZExtValue() const
Get zero extended value.
typename SuperClass::const_iterator const_iterator
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
STATISTIC(NumFunctions,"Total number of functions")
bool isVolatile() const
Return true if this is a store to a volatile memory location.
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...
This is the interface for a simple mod/ref and alias analysis over globals.
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
Value * getValue() const
Return the arguments to the instruction.
Implements a dense probed hash-table based set.
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 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.
A cache of .assume calls within a function.
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.
Analysis pass which computes a DominatorTree.
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.
The access modifies the value stored in memory.
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
The two locations may or may not alias. This is the least precise result.
unsigned arg_size() const
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
StringRef getName() const
Return a constant reference to the value's name.
AnalysisUsage & addRequired()
StructType * getStructTypeOrNull() const
#define INITIALIZE_PASS_DEPENDENCY(depName)
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
INITIALIZE_PASS_BEGIN(MemCpyOptLegacyPass,"memcpyopt","MemCpy Optimization", false, false) INITIALIZE_PASS_END(MemCpyOptLegacyPass
static int64_t GetOffsetFromIndex(const GEPOperator *GEP, unsigned Idx, bool &VariableIdxFound, const DataLayout &DL)
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
const APInt & getValue() const
Return the constant as an APInt value reference.
This class wraps the llvm.memmove intrinsic.
Class to represent struct types.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
An analysis that produces MemoryDependenceResults for a function.
friend const_iterator begin(StringRef path, Style style)
Get begin iterator over path.
void setArgument(unsigned ArgNo, Value *newVal)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
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.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
An instruction for storing to memory.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
uint64_t getElementOffset(unsigned Idx) const
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
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 ...
The access neither references nor modifies the value stored in memory.
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
friend const_iterator end(StringRef path)
Get end iterator over path.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
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...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
A manager for alias analyses.
std::pair< iterator, bool > insert(const ValueT &V)
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
Value * getRawDest() const
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...
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
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
static const unsigned End
FunctionPass * createMemCpyOptPass()
The public interface to this file...
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
self_iterator getIterator()
unsigned getIntegerBitWidth() const
static CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd)
Create a BitCast AddrSpaceCast, or a PtrToInt cast instruction.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void initializeMemCpyOptLegacyPassPass(PassRegistry &)
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
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_)
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
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.
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
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.
Iterator for intrusive lists based on ilist_node.
This is the shared class of boolean and integer constants.
InstrTy * getInstruction() const
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Value * getDest() const
This is just like getRawDest, but it strips off any cast instructions that feed it, giving the original input.
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...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
Provides information about what library functions are available for the current target.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Value * getLength() const
This class wraps the llvm.memcpy intrinsic.
Function * getCalledFunction() const
Return 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.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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...
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
bool mayThrow() const
Return true if this instruction may throw an exception.
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it...
void setCalledFunction(Value *Fn)
Set the function called.
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.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
This file provides utility analysis objects describing memory locations.
void preserveSet()
Mark an analysis set as preserved.
Establish a view to a call site for examination.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
Analysis pass providing the TargetLibraryInfo.
Value * getRawSource() const
Return the arguments to the instruction.
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.
void removeInstruction(Instruction *InstToRemove)
Removes an instruction from the dependence analysis, updating the dependence of instructions that pre...
const Value * getArraySize() const
Get the number of elements allocated.
print Print MemDeps of function
unsigned getLargestLegalIntTypeSizeInBits() const
Returns the size of largest legal integer type size, or 0 if none are set.
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
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...
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Value * getPointerOperand()
void combineMetadata(Instruction *K, const Instruction *J, ArrayRef< unsigned > KnownIDs)
Combine the metadata of two instructions so that K can replace J.
const BasicBlock * getParent() const
bool has(LibFunc F) const
Tests whether a library function is available.
A wrapper class for inspecting calls to intrinsic functions.
an instruction to allocate memory on the stack
gep_type_iterator gep_type_begin(const User *GEP)
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.