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");
100 bool isProfitableToUseMemset(
const DataLayout &DL)
const;
105 bool MemsetRange::isProfitableToUseMemset(
const DataLayout &DL)
const {
107 if (TheStores.size() >= 4 || End-Start >= 16)
return true;
110 if (TheStores.size() < 2)
return false;
115 if (!isa<StoreInst>(
SI))
120 if (TheStores.size() == 2)
return false;
132 unsigned Bytes =
unsigned(End-Start);
136 unsigned NumPointerStores = Bytes / MaxIntSize;
139 unsigned NumByteStores = Bytes % MaxIntSize;
144 return TheStores.size() > NumPointerStores+NumByteStores;
158 MemsetRanges(
const DataLayout &DL) : DL(DL) {}
162 const_iterator
begin()
const {
return Ranges.
begin(); }
163 const_iterator
end()
const {
return Ranges.
end(); }
166 void addInst(int64_t OffsetFromFirst,
Instruction *Inst) {
168 addStore(OffsetFromFirst,
SI);
170 addMemSet(OffsetFromFirst, cast<MemSetInst>(Inst));
173 void addStore(int64_t OffsetFromFirst,
StoreInst *
SI) {
176 addRange(OffsetFromFirst, StoreSize,
180 void addMemSet(int64_t OffsetFromFirst,
MemSetInst *MSI) {
181 int64_t
Size = cast<ConstantInt>(MSI->
getLength())->getZExtValue();
196 int64_t End = Start+
Size;
199 Ranges, [=](
const MemsetRange &
O) {
return O.End < Start; });
204 if (I == Ranges.
end() || End < I->Start) {
205 MemsetRange &R = *Ranges.
insert(I, MemsetRange());
209 R.Alignment = Alignment;
210 R.TheStores.push_back(Inst);
215 I->TheStores.push_back(Inst);
219 if (I->Start <= Start && I->End >= End)
228 if (Start < I->Start) {
231 I->Alignment = Alignment;
239 range_iterator NextI =
I;
240 while (++NextI != Ranges.
end() && End >= NextI->Start) {
242 I->TheStores.append(NextI->TheStores.begin(), NextI->TheStores.end());
243 if (NextI->End > I->End)
308 const DataLayout &DL = StartInst->getModule()->getDataLayout();
314 MemsetRanges Ranges(DL);
317 for (++BI; !BI->isTerminator(); ++BI) {
318 if (!isa<StoreInst>(BI) && !isa<MemSetInst>(BI)) {
322 if (BI->mayWriteToMemory() || BI->mayReadFromMemory())
327 if (
StoreInst *NextStore = dyn_cast<StoreInst>(BI)) {
329 if (!NextStore->isSimple())
break;
333 if (isa<UndefValue>(ByteVal) && StoredByte)
334 ByteVal = StoredByte;
335 if (ByteVal != StoredByte)
344 Ranges.addStore(*Offset, NextStore);
357 Ranges.addMemSet(*Offset, MSI);
369 Ranges.addInst(0, StartInst);
379 for (
const MemsetRange &Range : Ranges) {
380 if (Range.TheStores.size() == 1)
continue;
383 if (!Range.isProfitableToUseMemset(DL))
388 StartPtr = Range.StartPtr;
393 cast<PointerType>(StartPtr->getType())->getElementType());
395 AMemSet = Builder.
CreateMemSet(StartPtr, ByteVal, Range.End - Range.Start,
398 : Range.TheStores)
dbgs()
400 dbgs() <<
"With: " << *AMemSet <<
'\n');
402 if (!Range.TheStores.empty())
403 AMemSet->
setDebugLoc(Range.TheStores[0]->getDebugLoc());
407 MD->removeInstruction(SI);
467 bool NeedLift =
false;
489 else if (
const auto *Call = dyn_cast<CallBase>(
C)) {
495 }
else if (isa<LoadInst>(
C) || isa<StoreInst>(
C) || isa<VAArgInst>(
C)) {
501 MemLocs.push_back(ML);
509 if (
auto *A = dyn_cast<Instruction>(
C->
getOperand(k))) {
512 if(A == P)
return false;
520 LLVM_DEBUG(
dbgs() <<
"Lifting " << *I <<
" before " << *P <<
"\n");
543 if (LI->isSimple() && LI->hasOneUse() &&
546 auto *
T = LI->getType();
547 if (
T->isAggregateType()) {
568 if (!
moveUp(AA, SI, P, LI))
578 bool UseMemMove =
false;
595 LLVM_DEBUG(
dbgs() <<
"Promoting " << *LI <<
" to " << *SI <<
" => " 598 MD->removeInstruction(SI);
600 MD->removeInstruction(LI);
601 LI->eraseFromParent();
622 bool CpyDestIsLocal = isa<AllocaInst>(CpyDest);
633 if (I->mayThrow() && !CpyDestIsLocal) {
641 bool changed = performCallSlotOptzn(
647 MD->removeInstruction(SI);
649 MD->removeInstruction(LI);
650 LI->eraseFromParent();
668 BBI = I->getIterator();
675 auto *
T = V->getType();
676 if (
T->isAggregateType()) {
684 LLVM_DEBUG(
dbgs() <<
"Promoting " << *SI <<
" to " << *M <<
"\n");
686 MD->removeInstruction(SI);
691 BBI = M->getIterator();
705 BBI = I->getIterator();
715 Value *cpySrc, uint64_t cpyLen,
733 if (
F->isIntrinsic() &&
F->getIntrinsicID() == Intrinsic::lifetime_start)
753 if (cpyLen < srcSize)
759 if (
AllocaInst *A = dyn_cast<AllocaInst>(cpyDest)) {
768 if (destSize < srcSize)
770 }
else if (
Argument *A = dyn_cast<Argument>(cpyDest)) {
775 if (A->getDereferenceableBytes() < srcSize) {
778 if (!A->hasStructRetAttr())
781 Type *StructTy = cast<PointerType>(A->getType())->getElementType();
790 if (destSize < srcSize)
801 bool isDestSufficientlyAligned = srcAlign <= cpyAlign;
804 if (!isDestSufficientlyAligned && !isa<AllocaInst>(cpyDest))
813 while (!srcUseList.empty()) {
814 User *U = srcUseList.pop_back_val();
816 if (isa<BitCastInst>(U) || isa<AddrSpaceCastInst>(U)) {
818 srcUseList.push_back(UU);
822 if (!
G->hasAllZeroIndices())
826 srcUseList.push_back(UU);
830 if (
IT->isLifetimeStartOrEnd())
833 if (U != C && U != cpy)
839 for (
unsigned i = 0,
e = CS.
arg_size(); i !=
e; ++i)
846 if (
Instruction *cpyDestInst = dyn_cast<Instruction>(cpyDest))
867 for (
unsigned i = 0; i < CS.
arg_size(); ++i)
874 bool changedArgument =
false;
875 for (
unsigned i = 0; i < CS.
arg_size(); ++i)
880 changedArgument =
true;
888 if (!changedArgument)
892 if (!isDestSufficientlyAligned) {
893 assert(isa<AllocaInst>(cpyDest) &&
"Can only increase alloca alignment!");
894 cast<AllocaInst>(cpyDest)->setAlignment(
MaybeAlign(srcAlign));
899 MD->removeInstruction(C);
904 unsigned KnownIDs[] = {LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope,
905 LLVMContext::MD_noalias,
906 LLVMContext::MD_invariant_group,
907 LLVMContext::MD_access_group};
911 MD->removeInstruction(cpy);
919 bool MemCpyOptPass::processMemCpyMemCpyDependence(
MemCpyInst *M,
938 if (!MDepLen || !MLen || MDepLen->
getZExtValue() < MLen->getZExtValue())
964 bool UseMemMove =
false;
970 LLVM_DEBUG(
dbgs() <<
"MemCpyOptPass: Forwarding memcpy->memcpy src:\n" 971 << *MDep <<
'\n' << *M <<
'\n');
986 MD->removeInstruction(M);
1006 bool MemCpyOptPass::processMemSetMemCpyDependence(
MemCpyInst *MemCpy,
1016 if (DstDepInfo.
getInst() != MemSet)
1028 const unsigned DestAlign =
1031 if (
ConstantInt *SrcSizeC = dyn_cast<ConstantInt>(SrcSize))
1032 Align =
MinAlign(SrcSizeC->getZExtValue(), DestAlign);
1054 MD->removeInstruction(MemSet);
1062 if (isa<AllocaInst>(I))
1066 if (II->getIntrinsicID() == Intrinsic::lifetime_start)
1067 if (
ConstantInt *LTSize = dyn_cast<ConstantInt>(II->getArgOperand(0)))
1088 bool MemCpyOptPass::performMemCpyToMemSetOptzn(
MemCpyInst *MemCpy,
1114 CopySize = MemSetSize;
1130 bool MemCpyOptPass::processMemCpy(
MemCpyInst *M) {
1136 MD->removeInstruction(M);
1143 if (GV->isConstant() && GV->hasDefinitiveInitializer())
1149 MD->removeInstruction(M);
1161 if (processMemSetMemCpyDependence(M, MDep))
1166 if (!CopySize)
return false;
1183 MD->removeInstruction(M);
1191 MemDepResult SrcDepInfo = MD->getPointerDependencyFrom(
1196 return processMemCpyMemCpyDependence(M, MDep);
1197 }
else if (SrcDepInfo.
isDef()) {
1199 MD->removeInstruction(M);
1208 if (performMemCpyToMemSetOptzn(M, MDep)) {
1209 MD->removeInstruction(M);
1220 bool MemCpyOptPass::processMemMove(
MemMoveInst *M) {
1223 if (!TLI->has(LibFunc_memmove))
1231 LLVM_DEBUG(
dbgs() <<
"MemCpyOptPass: Optimizing memmove -> memcpy: " << *M
1239 Intrinsic::memcpy, ArgTys));
1243 MD->removeInstruction(M);
1250 bool MemCpyOptPass::processByValArgument(
CallSite CS,
unsigned ArgNo) {
1254 Type *ByValTy = cast<PointerType>(ByValArg->
getType())->getElementType();
1278 if (ByValAlign == 0)
return false;
1314 LLVM_DEBUG(
dbgs() <<
"MemCpyOptPass: Forwarding memcpy to byval:\n" 1315 <<
" " << *MDep <<
"\n" 1325 bool MemCpyOptPass::iterateOnFunction(
Function &
F) {
1326 bool MadeChange =
false;
1343 bool RepeatInstruction =
false;
1345 if (
StoreInst *SI = dyn_cast<StoreInst>(I))
1346 MadeChange |= processStore(SI, BI);
1347 else if (
MemSetInst *M = dyn_cast<MemSetInst>(I))
1348 RepeatInstruction = processMemSet(M, BI);
1349 else if (
MemCpyInst *M = dyn_cast<MemCpyInst>(I))
1350 RepeatInstruction = processMemCpy(M);
1351 else if (
MemMoveInst *M = dyn_cast<MemMoveInst>(I))
1352 RepeatInstruction = processMemMove(M);
1354 for (
unsigned i = 0,
e = CS.
arg_size(); i !=
e; ++i)
1356 MadeChange |= processByValArgument(CS, i);
1360 if (RepeatInstruction) {
1361 if (BI != BB.begin())
1385 bool MadeChange =
runImpl(F, &MD, &TLI, LookupAliasAnalysis,
1386 LookupAssumptionCache, LookupDomTree);
1402 bool MadeChange =
false;
1405 LookupAliasAnalysis = std::move(LookupAliasAnalysis_);
1406 LookupAssumptionCache = std::move(LookupAssumptionCache_);
1407 LookupDomTree = std::move(LookupDomTree_);
1412 if (!TLI->has(LibFunc_memset) || !TLI->has(LibFunc_memcpy))
1416 if (!iterateOnFunction(F))
1427 if (skipFunction(F))
1430 auto *MD = &getAnalysis<MemoryDependenceWrapperPass>().getMemDep();
1431 auto *TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
1434 return getAnalysis<AAResultsWrapperPass>().getAAResults();
1437 return getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
1440 return getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1443 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.
This class represents an incoming formal argument to a Function.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
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.
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.
void push_back(const T &Elt)
MaybeAlign getDestAlign() 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.
unsigned getSourceAlignment() const
FIXME: Remove this function once transition to Align is over.
A cache of @llvm.assume calls within a function.
static LocationSize precise(uint64_t Value)
bool erase(const ValueT &V)
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.
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.
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
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 ...
static Align findStoreAlignment(const DataLayout &DL, const StoreInst *SI)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
Type * getPointerElementType() const
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.
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
This class wraps the llvm.memmove intrinsic.
static bool hasUndefContents(Instruction *I, ConstantInt *Size)
Determine whether the instruction has undefined content for the given Size, either because it was fre...
An analysis that produces MemoryDependenceResults for a function.
unsigned getDestAlignment() const
FIXME: Remove this function once transition to Align is over.
Align commonAlignment(Align A, Align B)
Returns the alignment that satisfies both alignments.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
InstrTy * getInstruction() const
auto partition_point(R &&Range, Predicate P) -> decltype(adl_begin(Range))
Binary search for the first iterator in a range where a predicate is false.
void setArgument(unsigned ArgNo, Value *newVal)
Type * getType() const
All values are typed, get the type of this value.
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
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.
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="")
uint64_t value() const
This is a hole in the type system and should not be abused.
Align getValueOrABITypeAlignment(MaybeAlign Alignment, Type *Ty) const
Helper function to return Alignment if it's set or the result of getABITypeAlignment(Ty), in any case the result is a valid alignment.
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")
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.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
std::pair< iterator, bool > insert(const ValueT &V)
ValTy * getArgument(unsigned ArgNo) const
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.
static Align findCommonAlignment(const DataLayout &DL, const StoreInst *SI, const LoadInst *LI)
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
iterator erase(const_iterator CI)
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
This struct is a compact representation of a valid (non-zero power of two) alignment.
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 * isBytewiseValue(Value *V, const DataLayout &DL)
If the specified value can be set by repeating the same byte in memory, return the i8 value that it i...
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.
unsigned getNumOperands() const
This is the shared class of boolean and integer constants.
Align max(MaybeAlign Lhs, Align Rhs)
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
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 arg_size() const
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
MaybeAlign getSourceAlign() const
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.
Optional< int64_t > isPointerOffset(const Value *Ptr1, const Value *Ptr2, const DataLayout &DL)
If Ptr1 is provably equal to Ptr2 plus a constant offset, return that offset.
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.
iterator insert(iterator I, T &&Elt)
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")))
static Align findLoadAlignment(const DataLayout &DL, const LoadInst *LI)
CallInst * CreateMemMove(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
LLVM_NODISCARD bool isModSet(const ModRefInfo MRI)
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.
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 FIXME: Remove this function once transitio...
Analysis pass providing the TargetLibraryInfo.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
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.
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
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)
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
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
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, MaybeAlign 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.
static MemoryLocation getForSource(const MemTransferInst *MTI)
Return a location representing the source of a memory transfer.
FunTy * getCaller() const
Return the caller function for this call site.