42 #define DEBUG_TYPE "basicaa"
52 STATISTIC(SearchLimitReached,
"Number of times the limit to "
53 "decompose GEPs is reached");
54 STATISTIC(SearchTimes,
"Number of times a GEP is decomposed");
101 if (
const Argument *
A = dyn_cast<Argument>(V))
102 if (
A->hasByValAttr() ||
A->hasNoAliasAttr())
114 if (isa<CallInst>(V) || isa<InvokeInst>(V) || isa<Argument>(V))
120 if (isa<LoadInst>(V))
129 bool RoundToAlign =
false) {
200 const Value *BasicAAResult::GetLinearExpression(
213 if (
const ConstantInt *Const = dyn_cast<ConstantInt>(V)) {
220 assert(Scale == 0 &&
"Constant values don't have a scale");
225 if (
ConstantInt *RHSC = dyn_cast<ConstantInt>(BOp->getOperand(1))) {
232 switch (BOp->getOpcode()) {
239 case Instruction::Or:
250 V = GetLinearExpression(BOp->getOperand(0), Scale,
Offset, ZExtBits,
251 SExtBits, DL, Depth + 1, AC, DT, NSW, NUW);
254 case Instruction::Sub:
255 V = GetLinearExpression(BOp->getOperand(0), Scale,
Offset, ZExtBits,
256 SExtBits, DL, Depth + 1, AC, DT, NSW, NUW);
259 case Instruction::Mul:
260 V = GetLinearExpression(BOp->getOperand(0), Scale,
Offset, ZExtBits,
261 SExtBits, DL, Depth + 1, AC, DT, NSW, NUW);
265 case Instruction::Shl:
266 V = GetLinearExpression(BOp->getOperand(0), Scale,
Offset, ZExtBits,
267 SExtBits, DL, Depth + 1, AC, DT, NSW, NUW);
276 if (isa<OverflowingBinaryOperator>(BOp)) {
277 NUW &= BOp->hasNoUnsignedWrap();
278 NSW &= BOp->hasNoSignedWrap();
287 if (isa<SExtInst>(V) || isa<ZExtInst>(V)) {
288 Value *CastOp = cast<CastInst>(V)->getOperand(0);
291 unsigned OldZExtBits = ZExtBits, OldSExtBits = SExtBits;
292 const Value *Result =
293 GetLinearExpression(CastOp, Scale, Offset, ZExtBits, SExtBits, DL,
294 Depth + 1, AC, DT, NSW, NUW);
298 unsigned ExtendedBy = NewWidth - SmallWidth;
300 if (isa<SExtInst>(V) && ZExtBits == 0) {
306 unsigned OldWidth = Offset.getBitWidth();
307 Offset = Offset.trunc(SmallWidth).sext(NewWidth).zextOrSelf(OldWidth);
314 ZExtBits = OldZExtBits;
315 SExtBits = OldSExtBits;
317 SExtBits += ExtendedBy;
327 ZExtBits = OldZExtBits;
328 SExtBits = OldSExtBits;
330 ZExtBits += ExtendedBy;
346 assert(PointerSize <= 64 &&
"Invalid PointerSize!");
347 unsigned ShiftBits = 64 - PointerSize;
348 return (int64_t)((uint64_t)Offset << ShiftBits) >> ShiftBits;
364 bool BasicAAResult::DecomposeGEPExpression(
const Value *V,
371 Decomposed.StructOffset = 0;
372 Decomposed.OtherOffset = 0;
373 Decomposed.VarIndices.clear();
379 if (
const GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
380 if (!GA->isInterposable()) {
381 V = GA->getAliasee();
389 if (Op->
getOpcode() == Instruction::BitCast ||
390 Op->
getOpcode() == Instruction::AddrSpaceCast) {
398 if (
const Value *RV =
CS.getReturnedArgOperand()) {
431 bool GepHasConstantOffset =
true;
433 I !=
E; ++
I, ++GTI) {
438 unsigned FieldNo = cast<ConstantInt>(Index)->getZExtValue();
442 Decomposed.StructOffset +=
448 if (
const ConstantInt *CIdx = dyn_cast<ConstantInt>(Index)) {
451 Decomposed.OtherOffset +=
456 GepHasConstantOffset =
false;
459 unsigned ZExtBits = 0, SExtBits = 0;
464 if (PointerSize > Width)
465 SExtBits += PointerSize - Width;
468 APInt IndexScale(Width, 0), IndexOffset(Width, 0);
469 bool NSW =
true, NUW =
true;
470 Index = GetLinearExpression(Index, IndexScale, IndexOffset, ZExtBits,
471 SExtBits, DL, 0, AC, DT, NSW, NUW);
475 Decomposed.OtherOffset += IndexOffset.getSExtValue() * Scale;
476 Scale *= IndexScale.getSExtValue();
482 for (
unsigned i = 0, e = Decomposed.VarIndices.size(); i != e; ++i) {
483 if (Decomposed.VarIndices[i].V == Index &&
484 Decomposed.VarIndices[i].ZExtBits == ZExtBits &&
485 Decomposed.VarIndices[i].SExtBits == SExtBits) {
486 Scale += Decomposed.VarIndices[i].Scale;
487 Decomposed.VarIndices.erase(Decomposed.VarIndices.begin() + i);
497 VariableGEPIndex Entry = {Index, ZExtBits, SExtBits,
498 static_cast<int64_t
>(Scale)};
499 Decomposed.VarIndices.push_back(Entry);
504 if (GepHasConstantOffset) {
505 Decomposed.StructOffset =
507 Decomposed.OtherOffset =
513 }
while (--MaxLookup);
517 SearchLimitReached++;
526 assert(Visited.empty() &&
"Visited must be cleared after use!");
528 unsigned MaxLookup = 8;
533 if (!Visited.insert(V).second) {
539 if (OrLocal && isa<AllocaInst>(V))
547 if (!GV->isConstant()) {
563 if (
const PHINode *PN = dyn_cast<PHINode>(V)) {
565 if (PN->getNumIncomingValues() > MaxLookup) {
569 for (
Value *IncValue : PN->incoming_values())
578 }
while (!Worklist.
empty() && --MaxLookup);
581 return Worklist.
empty();
652 F == LibFunc_memset_pattern16 && TLI.
has(F))
686 if (
const Instruction *inst = dyn_cast<Instruction>(V)) {
687 if (!inst->getParent())
692 if (
const Argument *arg = dyn_cast<Argument>(V))
693 return arg->getParent();
703 return !F1 || !F2 || F1 == F2;
710 "BasicAliasAnalysis doesn't support interprocedural queries.");
715 auto CacheIt = AliasCache.
find(LocPair(LocA, LocB));
716 if (CacheIt != AliasCache.
end())
717 return CacheIt->second;
726 VisitedPhiBBs.clear();
739 "AliasAnalysis query involving multiple functions!");
748 if (isa<AllocaInst>(Object))
750 if (CI->isTailCall())
763 unsigned OperandNo = 0;
765 CI != CE; ++CI, ++OperandNo) {
769 if (!(*CI)->getType()->isPointerTy() ||
934 "Expected GEPs with the same pointer operand");
972 for (
unsigned i = 1, e = GEP1->
getNumIndices() - 1; i != e; ++i) {
983 if (isa<SequentialType>(Ty)) {
995 const uint64_t ElementSize =
997 if (V1Size != ElementSize || V2Size != ElementSize)
1000 for (
unsigned i = 0, e = GEP1->
getNumIndices() - 1; i != e; ++i)
1017 if (isa<PHINode>(GEP1LastIdx) || isa<PHINode>(GEP2LastIdx)) {
1024 if (GEP1LastIdx != GEP2LastIdx &&
1036 }
else if (!LastIndexedStruct || !C1 || !C2) {
1058 auto EltsDontOverlap = [StructSize](uint64_t V1Off, uint64_t V1Size,
1059 uint64_t V2Off, uint64_t V2Size) {
1060 return V1Off < V2Off && V1Off + V1Size <= V2Off &&
1061 ((V2Off + V2Size <= StructSize) ||
1062 (V2Off + V2Size - StructSize <= V1Off));
1065 if (EltsDontOverlap(V1Off, V1Size, V2Off, V2Size) ||
1066 EltsDontOverlap(V2Off, V2Size, V1Off, V1Size))
1103 bool BasicAAResult::isGEPBaseAtNegativeOffset(
const GEPOperator *GEPOp,
1104 const DecomposedGEP &DecompGEP,
const DecomposedGEP &DecompObject,
1105 uint64_t ObjectAccessSize) {
1113 if (!(isa<AllocaInst>(DecompObject.Base) ||
1114 isa<GlobalVariable>(DecompObject.Base)) ||
1115 !DecompObject.VarIndices.empty())
1118 int64_t ObjectBaseOffset = DecompObject.StructOffset +
1119 DecompObject.OtherOffset;
1126 int64_t GEPBaseOffset = DecompGEP.StructOffset;
1127 if (DecompGEP.VarIndices.empty())
1128 GEPBaseOffset += DecompGEP.OtherOffset;
1130 return (GEPBaseOffset >= ObjectBaseOffset + (int64_t)ObjectAccessSize);
1141 uint64_t V2Size,
const AAMDNodes &V2AAInfo,
1142 const Value *UnderlyingV1,
1143 const Value *UnderlyingV2) {
1144 DecomposedGEP DecompGEP1, DecompGEP2;
1145 bool GEP1MaxLookupReached =
1146 DecomposeGEPExpression(GEP1, DecompGEP1, DL, &AC, DT);
1147 bool GEP2MaxLookupReached =
1148 DecomposeGEPExpression(V2, DecompGEP2, DL, &AC, DT);
1150 int64_t GEP1BaseOffset = DecompGEP1.StructOffset + DecompGEP1.OtherOffset;
1151 int64_t GEP2BaseOffset = DecompGEP2.StructOffset + DecompGEP2.OtherOffset;
1153 assert(DecompGEP1.Base == UnderlyingV1 && DecompGEP2.Base == UnderlyingV2 &&
1154 "DecomposeGEPExpression returned a result different from "
1155 "GetUnderlyingObject");
1160 if (!GEP1MaxLookupReached && !GEP2MaxLookupReached &&
1161 isGEPBaseAtNegativeOffset(GEP1, DecompGEP1, DecompGEP2, V2Size))
1166 if (
const GEPOperator *GEP2 = dyn_cast<GEPOperator>(V2)) {
1169 if (!GEP1MaxLookupReached && !GEP2MaxLookupReached &&
1170 isGEPBaseAtNegativeOffset(GEP2, DecompGEP2, DecompGEP1, V1Size))
1179 if ((BaseAlias ==
MayAlias) && V1Size == V2Size) {
1181 AliasResult PreciseBaseAlias = aliasCheck(UnderlyingV1, V1Size, V1AAInfo,
1182 UnderlyingV2, V2Size, V2AAInfo);
1183 if (PreciseBaseAlias ==
NoAlias) {
1187 if (GEP2MaxLookupReached || GEP1MaxLookupReached)
1191 if (GEP1BaseOffset == GEP2BaseOffset &&
1192 DecompGEP1.VarIndices == DecompGEP2.VarIndices)
1218 if (GEP2MaxLookupReached || GEP1MaxLookupReached)
1223 GEP1BaseOffset -= GEP2BaseOffset;
1224 GetIndexDifference(DecompGEP1.VarIndices, DecompGEP2.VarIndices);
1238 V2AAInfo,
nullptr, UnderlyingV2);
1248 if (GEP1MaxLookupReached)
1258 if (GEP1BaseOffset == 0 && DecompGEP1.VarIndices.empty())
1265 if (GEP1BaseOffset != 0 && DecompGEP1.VarIndices.empty()) {
1266 if (GEP1BaseOffset >= 0) {
1268 if ((uint64_t)GEP1BaseOffset < V2Size)
1283 if (-(uint64_t)GEP1BaseOffset < V1Size)
1290 if (!DecompGEP1.VarIndices.empty()) {
1291 uint64_t Modulo = 0;
1292 bool AllPositive =
true;
1293 for (
unsigned i = 0, e = DecompGEP1.VarIndices.size(); i != e; ++i) {
1299 Modulo |= (uint64_t)DecompGEP1.VarIndices[i].Scale;
1305 const Value *V = DecompGEP1.VarIndices[i].V;
1313 bool IsZExt = DecompGEP1.VarIndices[i].ZExtBits > 0 || isa<ZExtInst>(V);
1314 SignKnownZero |= IsZExt;
1315 SignKnownOne &= !IsZExt;
1320 int64_t Scale = DecompGEP1.VarIndices[i].Scale;
1322 (SignKnownZero && Scale >= 0) || (SignKnownOne && Scale < 0);
1326 Modulo = Modulo ^ (Modulo & (Modulo - 1));
1331 uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1);
1334 V1Size <= Modulo - ModOffset)
1340 if (AllPositive && GEP1BaseOffset > 0 && V2Size <= (uint64_t)GEP1BaseOffset)
1343 if (constantOffsetHeuristic(DecompGEP1.VarIndices, V1Size, V2Size,
1344 GEP1BaseOffset, &AC, DT))
1370 const Value *V2, uint64_t V2Size,
1372 const Value *UnderV2) {
1375 if (
const SelectInst *SI2 = dyn_cast<SelectInst>(V2))
1378 SI2->getTrueValue(), V2Size, V2AAInfo);
1383 SI2->getFalseValue(), V2Size, V2AAInfo);
1391 SISize, SIAAInfo, UnderV2);
1396 aliasCheck(V2, V2Size, V2AAInfo, SI->
getFalseValue(), SISize, SIAAInfo,
1405 uint64_t V2Size,
const AAMDNodes &V2AAInfo,
1406 const Value *UnderV2) {
1414 if (
const PHINode *PN2 = dyn_cast<PHINode>(V2))
1415 if (PN2->getParent() == PN->
getParent()) {
1429 "There must exist an entry for the phi node");
1445 AliasCache[Locs] = OrigAliasResult;
1452 bool isRecursive =
false;
1454 if (isa<PHINode>(PV1))
1462 if (
GEPOperator *PV1GEP = dyn_cast<GEPOperator>(PV1)) {
1467 if (PV1GEP->getPointerOperand() == PN && PV1GEP->getNumIndices() == 1 &&
1468 isa<ConstantInt>(PV1GEP->idx_begin())) {
1474 if (UniqueSrc.
insert(PV1).second)
1485 aliasCheck(V2, V2Size, V2AAInfo, V1Srcs[0],
1486 PNSize, PNAAInfo, UnderV2);
1495 for (
unsigned i = 1, e = V1Srcs.
size(); i != e; ++i) {
1496 Value *V = V1Srcs[i];
1499 aliasCheck(V2, V2Size, V2AAInfo, V, PNSize, PNAAInfo, UnderV2);
1516 if (V1Size == 0 || V2Size == 0)
1525 if (isa<UndefValue>(V1) || isa<UndefValue>(V2))
1534 if (isValueEqualInPotentialCycles(V1, V2))
1550 if (CPN->getType()->getAddressSpace() == 0)
1553 if (CPN->getType()->getAddressSpace() == 0)
1606 std::pair<AliasCacheTy::iterator, bool> Pair =
1609 return Pair.first->second;
1613 if (!isa<GEPOperator>(V1) && isa<GEPOperator>(V2)) {
1619 if (
const GEPOperator *GV1 = dyn_cast<GEPOperator>(V1)) {
1621 aliasGEP(GV1, V1Size, V1AAInfo, V2, V2Size, V2AAInfo, O1, O2);
1623 return AliasCache[Locs] = Result;
1626 if (isa<PHINode>(V2) && !isa<PHINode>(V1)) {
1632 if (
const PHINode *PN = dyn_cast<PHINode>(V1)) {
1633 AliasResult Result = aliasPHI(PN, V1Size, V1AAInfo,
1634 V2, V2Size, V2AAInfo, O2);
1636 return AliasCache[Locs] = Result;
1639 if (isa<SelectInst>(V2) && !isa<SelectInst>(V1)) {
1645 if (
const SelectInst *S1 = dyn_cast<SelectInst>(V1)) {
1647 aliasSelect(S1, V1Size, V1AAInfo, V2, V2Size, V2AAInfo, O2);
1649 return AliasCache[Locs] = Result;
1665 return AliasCache[Locs] = Result;
1675 bool BasicAAResult::isValueEqualInPotentialCycles(
const Value *V,
1684 if (VisitedPhiBBs.empty())
1693 for (
auto *
P : VisitedPhiBBs)
1704 void BasicAAResult::GetIndexDifference(
1710 for (
unsigned i = 0, e = Src.
size(); i != e; ++i) {
1711 const Value *V = Src[i].V;
1712 unsigned ZExtBits = Src[i].ZExtBits, SExtBits = Src[i].SExtBits;
1713 int64_t Scale = Src[i].Scale;
1717 for (
unsigned j = 0, e = Dest.
size(); j != e; ++j) {
1718 if (!isValueEqualInPotentialCycles(Dest[j].V, V) ||
1719 Dest[j].ZExtBits != ZExtBits || Dest[j].SExtBits != SExtBits)
1724 if (Dest[j].Scale != Scale)
1725 Dest[j].Scale -= Scale;
1734 VariableGEPIndex Entry = {V, ZExtBits, SExtBits, -Scale};
1740 bool BasicAAResult::constantOffsetHeuristic(
1748 const VariableGEPIndex &Var0 = VarIndices[0], &Var1 = VarIndices[1];
1750 if (Var0.ZExtBits != Var1.ZExtBits || Var0.SExtBits != Var1.SExtBits ||
1751 Var0.Scale != -Var1.Scale)
1754 unsigned Width = Var1.V->getType()->getIntegerBitWidth();
1760 APInt V0Scale(Width, 0), V0Offset(Width, 0), V1Scale(Width, 0),
1762 bool NSW =
true, NUW =
true;
1763 unsigned V0ZExtBits = 0, V0SExtBits = 0, V1ZExtBits = 0, V1SExtBits = 0;
1764 const Value *V0 = GetLinearExpression(Var0.V, V0Scale, V0Offset, V0ZExtBits,
1765 V0SExtBits, DL, 0, AC, DT, NSW, NUW);
1768 const Value *V1 = GetLinearExpression(Var1.V, V1Scale, V1Offset, V1ZExtBits,
1769 V1SExtBits, DL, 0, AC, DT, NSW, NUW);
1771 if (V0Scale != V1Scale || V0ZExtBits != V1ZExtBits ||
1772 V0SExtBits != V1SExtBits || !isValueEqualInPotentialCycles(V0, V1))
1782 APInt MinDiff = V0Offset - V1Offset, Wrapped = -MinDiff;
1790 return V1Size +
std::abs(BaseOffset) <= MinDiffBytes &&
1791 V2Size +
std::abs(BaseOffset) <= MinDiffBytes;
1813 void BasicAAWrapperPass::anchor() {}
1816 "Basic Alias Analysis (stateless AA impl)",
true,
true)
1824 return new BasicAAWrapperPass();
1828 auto &ACT = getAnalysis<AssumptionCacheTracker>();
1829 auto &TLIWP = getAnalysis<TargetLibraryInfoWrapperPass>();
1830 auto &DTWP = getAnalysis<DominatorTreeWrapperPass>();
1831 auto *LIWP = getAnalysisIfAvailable<LoopInfoWrapperPass>();
1834 ACT.getAssumptionCache(F), &DTWP.getDomTree(),
1835 LIWP ? &LIWP->getLoopInfo() :
nullptr));
Pass interface - Implemented by all 'passes'.
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.
The two locations precisely alias each other.
static const unsigned MaxLookupSearchDepth
Type * getSourceElementType() const
void push_back(const T &Elt)
Basic Alias Analysis(stateless AA impl)"
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events in the new pass manager.
A parsed version of the target data layout string in and methods for querying it. ...
Type * getIndexedType() const
BasicAAResult(const DataLayout &DL, const TargetLibraryInfo &TLI, AssumptionCache &AC, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static bool isIntrinsicCall(ImmutableCallSite CS, Intrinsic::ID IID)
This class represents an incoming formal argument to a Function.
uint64_t getZExtValue() const
Get zero extended value.
STATISTIC(NumFunctions,"Total number of functions")
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
BasicAAResult createLegacyPMBasicAAResult(Pass &P, Function &F)
A helper for the legacy pass manager to create a BasicAAResult object populated to the best of our ab...
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
unsigned getNumOperands() const
The two locations alias, but only due to a partial overlap.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
This class represents a function call, abstracting a target machine's calling convention.
static bool isEscapeSource(const Value *V)
Returns true if the pointer is one which would have been considered an escape by isNonEscapingLocalOb...
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of .assume calls within a function.
bool RoundToAlign
Whether to round the result up to the alignment of allocas, byval arguments, and global variables...
This is the AA result object for the basic, local, and stateless alias analysis.
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
The two locations do not alias at all.
Analysis pass which computes a DominatorTree.
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
Chases pointers until we find a (constant global) or not.
The access modifies the value stored in memory.
The two locations may or may not alias. This is the least precise result.
INITIALIZE_PASS_BEGIN(BasicAAWrapperPass,"basicaa","Basic Alias Analysis (stateless AA impl)", true, true) INITIALIZE_PASS_END(BasicAAWrapperPass
This indicates that the function could not be classified into one of the behaviors above...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
AnalysisUsage & addRequired()
StructType * getStructTypeOrNull() const
The only memory references in this function (if it has any) are references of memory that is otherwis...
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool isNonNegative() const
Returns true if this value is known to be non-negative.
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
This class represents the LLVM 'select' instruction.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
const Value * stripPointerCastsAndBarriers() const
Strip off pointer casts, all-zero GEPs, aliases and barriers.
Class to represent struct types.
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value...
A Use represents the edge between a Value definition and its users.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
const unsigned MaxNumPhiBBsValueReachabilityCheck
Cutoff after which to stop analysing a set of phi nodes potentially involved in a cycle...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
bool doesNotReadMemory() const
Determine if the function does not access or only writes memory.
static AliasResult MergeAliasResults(AliasResult A, AliasResult B)
The access references the value stored in memory.
Analysis pass that exposes the LoopInfo for a function.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The function may perform non-volatile loads and stores of objects pointed to by its pointer-typed arg...
LLVM_NODISCARD bool empty() const
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
place backedge safepoints impl
IterTy data_operands_begin() const
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
APInt zextOrSelf(unsigned width) const
Zero extend or truncate to width.
static MemoryLocation getForDest(const MemIntrinsic *MI)
Return a location representing the destination of a memory set or transfer.
static cl::opt< bool > EnableRecPhiAnalysis("basicaa-recphi", cl::Hidden, cl::init(false))
Enable analysis of recursive PHI nodes.
FunctionModRefBehavior
Summary of how a function affects memory in the program.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
bool doesNotAccessMemory() const
Determine if the function does not access memory.
static bool isObjectSize(const Value *V, uint64_t Size, const DataLayout &DL, const TargetLibraryInfo &TLI)
Returns true if we can prove that the object specified by V has size Size.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
bool hasOperandBundles() const
iterator find(const_arg_type_t< KeyT > Val)
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.
The access neither references nor modifies the value stored in memory.
initializer< Ty > init(const Ty &Val)
A set of analyses that are preserved following a run of a transformation pass.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
bool isNegative() const
Returns true if this value is known to be negative.
static bool isWriteOnlyParam(ImmutableCallSite CS, unsigned ArgIdx, const TargetLibraryInfo &TLI)
Returns true if this is a writeonly (i.e Mod only) parameter.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
const Value * getCondition() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool MaskedValueIsZero(const Value *V, const APInt &Mask, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Return true if 'V & Mask' is known to be zero.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
Returns the behavior when calling the given call site.
AliasResult
The possible results of an alias query.
Represent the analysis usage information of a pass.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
unsigned getBitWidth() const
Return the number of bits in the APInt.
The only memory references in this function (if it has any) are non-volatile loads and stores from ob...
Value * getPointerOperand()
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
bool isPotentiallyReachable(const Instruction *From, const Instruction *To, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether instruction 'To' is reachable from 'From', returning true if uncertain.
unsigned getIntegerBitWidth() const
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
Checks to see if the specified callsite can clobber the specified memory object.
static bool isNonEscapingLocalObject(const Value *V)
Returns true if the pointer is to a function-local object that never escapes from the function...
bool isPointerTy() const
True if this is an instance of PointerType.
iterator erase(const_iterator CI)
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures, bool StoreCaptures)
PointerMayBeCaptured - Return true if this pointer value may be captured by the enclosing function (w...
static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1, uint64_t V1Size, const GEPOperator *GEP2, uint64_t V2Size, const DataLayout &DL)
Provide ad-hoc rules to disambiguate accesses through two GEP operators, both having the exact same p...
const Value * getTrueValue() const
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
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...
This function does not perform any non-local loads or stores to memory.
static int64_t adjustToPointerSize(int64_t Offset, unsigned PointerSize)
To ensure a pointer offset fits in an integer of size PointerSize (in bits) when that size is smaller...
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
bool doesNotAccessMemory() const
Determine if the call does not access memory.
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
A function analysis which provides an AssumptionCache.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
bool doesNotReadMemory() const
Determine if the call does not access or only writes memory.
InstrTy * getInstruction() const
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
unsigned getNumIndices() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
This is a utility class that provides an abstraction for the common functionality between Instruction...
Type * getType() const
All values are typed, get the type of this value.
static bool isObjectSmallerThan(const Value *V, uint64_t Size, const DataLayout &DL, const TargetLibraryInfo &TLI)
Returns true if we can prove that the object specified by V is smaller than Size. ...
Provides information about what library functions are available for the current target.
A constant pointer value that points to null.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
LLVM_NODISCARD T pop_back_val()
uint64_t getSizeInBytes() const
This function does not perform any non-local stores or volatile loads, but may read from any memory l...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
unsigned getNumArgOperands() const
Class for arbitrary precision integers.
static bool notDifferentParent(const Value *O1, const Value *O2)
FunctionPass * createBasicAAWrapperPass()
bool isIntegerTy() const
True if this is an instance of IntegerType.
void setPreservesAll()
Set by analyses that do not transform their input at all.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the type of the element that would be loaded with a load instruction with the specified param...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
AAMDNodes AATags
The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...
bool isKnownNonNull(const Value *V)
Return true if this pointer couldn't possibly be null by its definition.
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the call or the callee has the given attribute.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
bool isMallocOrCallocLikeFn(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 similar to malloc or...
Establish a view to a call site for examination.
The access both references and modifies the value stored in memory.
AAResultsProxy getBestAAResults()
Get a proxy for the best AA result set to query at this time.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
APFloat abs(APFloat X)
Returns the absolute value of the argument.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getPointerAddressSpace() const
Method to return the address space of the pointer operand.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
bool isKnownNonEqual(const Value *V1, const Value *V2, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Return true if the given values are known to be non-equal when defined.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
BasicAAResult run(Function &F, FunctionAnalysisManager &AM)
API to communicate dependencies between analyses during invalidation.
Analysis pass providing the TargetLibraryInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
Get the location associated with a pointer argument of a callsite.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static const Function * getParent(const Value *V)
const Value * getFalseValue() const
This is the interface for LLVM's primary stateless and local alias analysis.
Various options to control the behavior of getObjectSize.
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
IterTy data_operands_end() const
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Trigger the invalidation of some other analysis pass if not already handled and return whether it was...
op_range incoming_values()
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
A special type used by analysis passes to provide an address that identifies that particular analysis...
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.
void initializeBasicAAWrapperPassPass(PassRegistry &)
Legacy wrapper pass to provide the BasicAAResult object.
gep_type_iterator gep_type_begin(const User *GEP)
uint64_t Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known...
static MemoryLocation getForSource(const MemTransferInst *MTI)
Return a location representing the source of a memory transfer.