Index: llvm/include/llvm/Analysis/AliasAnalysis.h =================================================================== --- llvm/include/llvm/Analysis/AliasAnalysis.h +++ llvm/include/llvm/Analysis/AliasAnalysis.h @@ -407,7 +407,8 @@ /// A convenience wrapper around the primary \c alias interface. AliasResult alias(const Value *V1, const Value *V2) { - return alias(V1, LocationSize::unknown(), V2, LocationSize::unknown()); + return alias(MemoryLocation::getBasedOn(V1), + MemoryLocation::getBasedOn(V2)); } /// A trivial helper function to check to see if the specified pointers are @@ -424,8 +425,8 @@ /// A convenience wrapper around the \c isNoAlias helper interface. bool isNoAlias(const Value *V1, const Value *V2) { - return isNoAlias(MemoryLocation(V1, LocationSize::unknown()), - MemoryLocation(V2, LocationSize::unknown())); + return isNoAlias(MemoryLocation::getBasedOn(V1), + MemoryLocation::getBasedOn(V2)); } /// A trivial helper function to check to see if the specified pointers are @@ -447,8 +448,7 @@ /// A convenience wrapper around the primary \c pointsToConstantMemory /// interface. bool pointsToConstantMemory(const Value *P, bool OrLocal = false) { - return pointsToConstantMemory(MemoryLocation(P, LocationSize::unknown()), - OrLocal); + return pointsToConstantMemory(MemoryLocation::getBasedOn(P), OrLocal); } /// @} Index: llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h =================================================================== --- llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -302,7 +302,7 @@ /// The maximum size of the dereferences of the pointer. /// /// May be UnknownSize if the sizes are unknown. - LocationSize Size = LocationSize::unknown(); + LocationSize Size = LocationSize::unknownNonNegative(); /// The AA tags associated with dereferences of the pointer. /// /// The members may be null if there are no tags or conflicting tags. Index: llvm/include/llvm/Analysis/MemoryLocation.h =================================================================== --- llvm/include/llvm/Analysis/MemoryLocation.h +++ llvm/include/llvm/Analysis/MemoryLocation.h @@ -64,10 +64,11 @@ // None. class LocationSize { enum : uint64_t { - Unknown = ~uint64_t(0), + UnknownMaybeNegative = ~uint64_t(0), + UnknownNonNegative = UnknownMaybeNegative - 1, + MapEmpty = UnknownMaybeNegative - 2, + MapTombstone = UnknownMaybeNegative - 3, ImpreciseBit = uint64_t(1) << 63, - MapEmpty = Unknown - 1, - MapTombstone = Unknown - 2, // The maximum value we can represent without falling back to 'unknown'. MaxValue = (MapTombstone - 1) & ~ImpreciseBit, @@ -81,7 +82,11 @@ constexpr LocationSize(uint64_t Raw, DirectConstruction): Value(Raw) {} - static_assert(Unknown & ImpreciseBit, "Unknown is imprecise by definition."); + static_assert(UnknownNonNegative & ImpreciseBit, + "UnknownNonNegative is imprecise by definition."); + static_assert(UnknownMaybeNegative & ImpreciseBit, + "UnknownMaybeNegative is imprecise by definition."); + public: // FIXME: Migrate all users to construct via either `precise` or `upperBound`, // to make it more obvious at the callsite the kind of size that they're @@ -90,12 +95,12 @@ // Since the overwhelming majority of users of this provide precise values, // this assumes the provided value is precise. constexpr LocationSize(uint64_t Raw) - : Value(Raw > MaxValue ? Unknown : Raw) {} + : Value(Raw > MaxValue ? UnknownNonNegative : Raw) {} static LocationSize precise(uint64_t Value) { return LocationSize(Value); } static LocationSize precise(TypeSize Value) { if (Value.isScalable()) - return unknown(); + return unknownNonNegative(); return precise(Value.getFixedSize()); } @@ -104,17 +109,25 @@ if (LLVM_UNLIKELY(Value == 0)) return precise(0); if (LLVM_UNLIKELY(Value > MaxValue)) - return unknown(); + return unknownNonNegative(); return LocationSize(Value | ImpreciseBit, Direct); } static LocationSize upperBound(TypeSize Value) { if (Value.isScalable()) - return unknown(); + return unknownNonNegative(); return upperBound(Value.getFixedSize()); } - constexpr static LocationSize unknown() { - return LocationSize(Unknown, Direct); + /// Unknown, but non-negative, location size. This means that only memory + /// after the base pointer may be accessed. + constexpr static LocationSize unknownNonNegative() { + return LocationSize(UnknownNonNegative, Direct); + } + + /// Completely unknown location size, which also permits accesses before the + /// base pointer. + constexpr static LocationSize unknownMaybeNegative() { + return LocationSize(UnknownMaybeNegative, Direct); } // Sentinel values, generally used for maps. @@ -131,20 +144,24 @@ if (Other == *this) return *this; - if (!hasValue() || !Other.hasValue()) - return unknown(); + if (Value == UnknownMaybeNegative || Other.Value == UnknownMaybeNegative) + return unknownMaybeNegative(); + if (Value == UnknownNonNegative || Other.Value == UnknownNonNegative) + return unknownNonNegative(); return upperBound(std::max(getValue(), Other.getValue())); } - bool hasValue() const { return Value != Unknown; } + bool hasValue() const { + return Value != UnknownNonNegative && Value != UnknownMaybeNegative; + } uint64_t getValue() const { assert(hasValue() && "Getting value from an unknown LocationSize!"); return Value & ~ImpreciseBit; } // Returns whether or not this value is precise. Note that if a value is - // precise, it's guaranteed to not be `unknown()`. + // precise, it's guaranteed to not be unknown. bool isPrecise() const { return (Value & ImpreciseBit) == 0; } @@ -152,6 +169,9 @@ // Convenience method to check if this LocationSize's value is 0. bool isZero() const { return hasValue() && getValue() == 0; } + /// Whether accesses below the base pointer are possible. + bool mayBeNegative() const { return Value == UnknownMaybeNegative; } + bool operator==(const LocationSize &Other) const { return Value == Other.Value; } @@ -242,13 +262,26 @@ return getForArgument(Call, ArgIdx, &TLI); } + /// Return a location that may access any memory starting at Ptr. The access + /// may occur with any size at Ptr or at some positive offset of Ptr. + static MemoryLocation getStartingFrom(const Value *Ptr) { + return MemoryLocation(Ptr, LocationSize::unknownNonNegative()); + } + + /// Return a location that may access any memory based on Ptr. This includes + /// accesses below Ptr, but still part of the same underlying object. + static MemoryLocation getBasedOn(const Value *Ptr) { + return MemoryLocation(Ptr, LocationSize::unknownMaybeNegative()); + } + // Return the exact size if the exact size is known at compiletime, // otherwise return MemoryLocation::UnknownSize. static uint64_t getSizeOrUnknown(const TypeSize &T) { return T.isScalable() ? UnknownSize : T.getFixedSize(); } - MemoryLocation() : Ptr(nullptr), Size(LocationSize::unknown()), AATags() {} + MemoryLocation() + : Ptr(nullptr), Size(LocationSize::unknownMaybeNegative()), AATags() {} explicit MemoryLocation(const Value *Ptr, LocationSize Size, const AAMDNodes &AATags = AAMDNodes()) Index: llvm/include/llvm/Analysis/MemorySSA.h =================================================================== --- llvm/include/llvm/Analysis/MemorySSA.h +++ llvm/include/llvm/Analysis/MemorySSA.h @@ -1248,7 +1248,8 @@ // catch loop carried dependences. if (Location.Ptr && !IsGuaranteedLoopInvariant(const_cast(Location.Ptr))) - CurrentPair.second = Location.getWithNewSize(LocationSize::unknown()); + CurrentPair.second = + Location.getWithNewSize(LocationSize::unknownMaybeNegative()); PHITransAddr Translator( const_cast(Location.Ptr), OriginalAccess->getBlock()->getModule()->getDataLayout(), nullptr); @@ -1262,8 +1263,8 @@ if (TransAddr && !IsGuaranteedLoopInvariant(const_cast(TransAddr))) - CurrentPair.second = - CurrentPair.second.getWithNewSize(LocationSize::unknown()); + CurrentPair.second = CurrentPair.second.getWithNewSize( + LocationSize::unknownMaybeNegative()); if (PerformedPhiTranslation) *PerformedPhiTranslation = true; Index: llvm/include/llvm/LinkAllPasses.h =================================================================== --- llvm/include/llvm/LinkAllPasses.h +++ llvm/include/llvm/LinkAllPasses.h @@ -239,7 +239,7 @@ llvm::TargetLibraryInfo TLI(TLII); llvm::AliasAnalysis AA(TLI); llvm::AliasSetTracker X(AA); - X.add(nullptr, llvm::LocationSize::unknown(), + X.add(nullptr, llvm::LocationSize::unknownNonNegative(), llvm::AAMDNodes()); // for -print-alias-sets (void) llvm::AreStatisticsEnabled(); (void) llvm::sys::RunningOnValgrind(); Index: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp =================================================================== --- llvm/lib/Analysis/AliasAnalysisEvaluator.cpp +++ llvm/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -140,13 +140,13 @@ // iterate over the worklist, and run the full (n^2)/2 disambiguations for (SetVector::iterator I1 = Pointers.begin(), E = Pointers.end(); I1 != E; ++I1) { - auto I1Size = LocationSize::unknown(); + auto I1Size = LocationSize::unknownNonNegative(); Type *I1ElTy = cast((*I1)->getType())->getElementType(); if (I1ElTy->isSized()) I1Size = LocationSize::precise(DL.getTypeStoreSize(I1ElTy)); for (SetVector::iterator I2 = Pointers.begin(); I2 != I1; ++I2) { - auto I2Size = LocationSize::unknown(); + auto I2Size = LocationSize::unknownNonNegative(); Type *I2ElTy = cast((*I2)->getType())->getElementType(); if (I2ElTy->isSized()) I2Size = LocationSize::precise(DL.getTypeStoreSize(I2ElTy)); @@ -231,7 +231,7 @@ // Mod/ref alias analysis: compare all pairs of calls and values for (CallBase *Call : Calls) { for (auto Pointer : Pointers) { - auto Size = LocationSize::unknown(); + auto Size = LocationSize::unknownNonNegative(); Type *ElTy = cast(Pointer->getType())->getElementType(); if (ElTy->isSized()) Size = LocationSize::precise(DL.getTypeStoreSize(ElTy)); Index: llvm/lib/Analysis/AliasSetTracker.cpp =================================================================== --- llvm/lib/Analysis/AliasSetTracker.cpp +++ llvm/lib/Analysis/AliasSetTracker.cpp @@ -670,8 +670,10 @@ for (iterator I = begin(), E = end(); I != E; ++I) { if (I != begin()) OS << ", "; I.getPointer()->printAsOperand(OS << "("); - if (I.getSize() == LocationSize::unknown()) - OS << ", unknown)"; + if (I.getSize() == LocationSize::unknownNonNegative()) + OS << ", unknown non-negative)"; + else if (I.getSize() == LocationSize::unknownMaybeNegative()) + OS << ", unknown maybe-negative)"; else OS << ", " << I.getSize() << ")"; } Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp =================================================================== --- llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -876,8 +876,8 @@ // If this is a no-capture pointer argument, see if we can tell that it // is impossible to alias the pointer we're checking. AliasResult AR = getBestAAResults().alias( - MemoryLocation(*CI, LocationSize::unknown()), - MemoryLocation(Object, LocationSize::unknown()), AAQI); + MemoryLocation::getBasedOn(*CI), MemoryLocation::getBasedOn(Object), + AAQI); if (AR != MustAlias) IsMustAlias = false; // Operand doesn't alias 'Object', continue looking for other aliases @@ -923,8 +923,8 @@ if (isMallocOrCallocLikeFn(Call, &TLI)) { // Be conservative if the accessed pointer may alias the allocation - // fallback to the generic handling below. - if (getBestAAResults().alias(MemoryLocation(Call, LocationSize::unknown()), - Loc, AAQI) == NoAlias) + if (getBestAAResults().alias(MemoryLocation::getBasedOn(Call), Loc, AAQI) + == NoAlias) return ModRefInfo::NoModRef; } @@ -1254,9 +1254,9 @@ if (isGEPBaseAtNegativeOffset(GEP2, DecompGEP2, DecompGEP1, V1Size)) return NoAlias; // Do the base pointers alias? - AliasResult BaseAlias = - aliasCheck(UnderlyingV1, LocationSize::unknown(), AAMDNodes(), - UnderlyingV2, LocationSize::unknown(), AAMDNodes(), AAQI); + AliasResult BaseAlias = aliasCheck( + UnderlyingV1, LocationSize::unknownMaybeNegative(), AAMDNodes(), + UnderlyingV2, LocationSize::unknownMaybeNegative(), AAMDNodes(), AAQI); // For GEPs with identical offsets, we can preserve the size and AAInfo // when performing the alias check on the underlying objects. @@ -1304,9 +1304,9 @@ if (!V1Size.hasValue() && !V2Size.hasValue()) return MayAlias; - AliasResult R = aliasCheck(UnderlyingV1, LocationSize::unknown(), - AAMDNodes(), V2, LocationSize::unknown(), - V2AAInfo, AAQI, nullptr, UnderlyingV2); + AliasResult R = aliasCheck( + UnderlyingV1, LocationSize::unknownMaybeNegative(), AAMDNodes(), + V2, V2Size, V2AAInfo, AAQI, nullptr, UnderlyingV2); if (R != MustAlias) { // If V2 may alias GEP base pointer, conservatively returns MayAlias. // If V2 is known not to alias GEP base pointer, then the two values @@ -1597,7 +1597,10 @@ // unknown to represent all the possible values the GEP could advance the // pointer to. if (isRecursive) - PNSize = LocationSize::unknown(); + // TODO: We are checking above that the addrec GEP has a positive offset + // and can thus use a non-negative location size here. It might be better + // to drop the offset requirement and use unknownMaybeNegative(). + PNSize = LocationSize::unknownNonNegative(); // In the recursive alias queries below, we may compare values from two // different loop iterations. Keep track of visited phi blocks, which will @@ -1735,6 +1738,17 @@ TLI, NullIsValidLocation))) return NoAlias; + // If one the accesses may be negative (i.e. below the accessed pointer), + // canonicalize this by using unknown non-negative sizes for both accesses. + // This is equivalent, because regardless of which pointer is lower, the + // non-negative unknown sizes will always intersect. We do this so that the + // rest of BasicAA does not have to deal with negative access sizes, and to + // improve cache utilization by merging equivalent states. + if (V1Size.mayBeNegative() || V2Size.mayBeNegative()) { + V1Size = LocationSize::unknownNonNegative(); + V2Size = LocationSize::unknownNonNegative(); + } + // Check the cache before climbing up use-def chains. This also terminates // otherwise infinitely recursive queries. AAQueryInfo::LocPair Locs(MemoryLocation(V1, V1Size, V1AAInfo), Index: llvm/lib/Analysis/DependenceAnalysis.cpp =================================================================== --- llvm/lib/Analysis/DependenceAnalysis.cpp +++ llvm/lib/Analysis/DependenceAnalysis.cpp @@ -653,8 +653,10 @@ const MemoryLocation &LocB) { // Check the original locations (minus size) for noalias, which can happen for // tbaa, incompatible underlying object locations, etc. - MemoryLocation LocAS(LocA.Ptr, LocationSize::unknown(), LocA.AATags); - MemoryLocation LocBS(LocB.Ptr, LocationSize::unknown(), LocB.AATags); + MemoryLocation LocAS(LocA.Ptr, LocationSize::unknownMaybeNegative(), + LocA.AATags); + MemoryLocation LocBS(LocB.Ptr, LocationSize::unknownMaybeNegative(), + LocB.AATags); if (AA->alias(LocAS, LocBS) == NoAlias) return NoAlias; Index: llvm/lib/Analysis/GlobalsModRef.cpp =================================================================== --- llvm/lib/Analysis/GlobalsModRef.cpp +++ llvm/lib/Analysis/GlobalsModRef.cpp @@ -921,9 +921,8 @@ if (!all_of(Objects, isIdentifiedObject) && // Try ::alias to see if all objects are known not to alias GV. !all_of(Objects, [&](const Value *V) { - return this->alias(MemoryLocation(V, LocationSize::unknown()), - MemoryLocation(GV, LocationSize::unknown()), - AAQI) == NoAlias; + return this->alias(MemoryLocation::getBasedOn(V), + MemoryLocation::getBasedOn(GV), AAQI) == NoAlias; })) return ConservativeResult; Index: llvm/lib/Analysis/Lint.cpp =================================================================== --- llvm/lib/Analysis/Lint.cpp +++ llvm/lib/Analysis/Lint.cpp @@ -190,8 +190,8 @@ void Lint::visitCallBase(CallBase &I) { Value *Callee = I.getCalledOperand(); - visitMemoryReference(I, MemoryLocation(Callee, LocationSize::unknown()), - None, nullptr, MemRef::Callee); + visitMemoryReference(I, MemoryLocation::getStartingFrom(Callee), None, + nullptr, MemRef::Callee); if (Function *F = dyn_cast(findValue(Callee, /*OffsetOk=*/false))) { @@ -295,7 +295,7 @@ // Check that the memcpy arguments don't overlap. The AliasAnalysis API // isn't expressive enough for what we really want to do. Known partial // overlap is not distinguished from the case where nothing is known. - auto Size = LocationSize::unknown(); + auto Size = LocationSize::unknownNonNegative(); if (const ConstantInt *Len = dyn_cast(findValue(MCI->getLength(), /*OffsetOk=*/false))) @@ -586,9 +586,8 @@ } void Lint::visitIndirectBrInst(IndirectBrInst &I) { - visitMemoryReference( - I, MemoryLocation(I.getAddress(), LocationSize::unknown()), - None, nullptr, MemRef::Branchee); + visitMemoryReference(I, MemoryLocation::getStartingFrom(I.getAddress()), + None, nullptr, MemRef::Branchee); Assert(I.getNumDestinations() != 0, "Undefined behavior: indirectbr with no destinations", &I); Index: llvm/lib/Analysis/LoopAccessAnalysis.cpp =================================================================== --- llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -518,7 +518,7 @@ /// Register a load and whether it is only read from. void addLoad(MemoryLocation &Loc, bool IsReadOnly) { Value *Ptr = const_cast(Loc.Ptr); - AST.add(Ptr, LocationSize::unknown(), Loc.AATags); + AST.add(Ptr, LocationSize::unknownMaybeNegative(), Loc.AATags); Accesses.insert(MemAccessInfo(Ptr, false)); if (IsReadOnly) ReadOnlyPtr.insert(Ptr); @@ -527,7 +527,7 @@ /// Register a store. void addStore(MemoryLocation &Loc) { Value *Ptr = const_cast(Loc.Ptr); - AST.add(Ptr, LocationSize::unknown(), Loc.AATags); + AST.add(Ptr, LocationSize::unknownMaybeNegative(), Loc.AATags); Accesses.insert(MemAccessInfo(Ptr, true)); } Index: llvm/lib/Analysis/MemoryDependenceAnalysis.cpp =================================================================== --- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -148,7 +148,7 @@ if (const CallInst *CI = isFreeCall(Inst, &TLI)) { // calls to free() deallocate the entire structure - Loc = MemoryLocation(CI->getArgOperand(0), LocationSize::unknown()); + Loc = MemoryLocation::getStartingFrom(CI->getArgOperand(0)); return ModRefInfo::Mod; } @@ -455,7 +455,8 @@ // pointer, not on query pointers that are indexed off of them. It'd // be nice to handle that at some point (the right approach is to use // GetPointerBaseWithConstantOffset). - MemoryLocation ArgLoc(II->getArgOperand(1), LocationSize::unknown()); + MemoryLocation ArgLoc = + MemoryLocation::getStartingFrom(II->getArgOperand(1)); if (BatchAA.isMustAlias(ArgLoc, MemLoc)) return MemDepResult::getDef(II); continue; Index: llvm/lib/Analysis/MemoryLocation.cpp =================================================================== --- llvm/lib/Analysis/MemoryLocation.cpp +++ llvm/lib/Analysis/MemoryLocation.cpp @@ -20,8 +20,10 @@ void LocationSize::print(raw_ostream &OS) const { OS << "LocationSize::"; - if (*this == unknown()) - OS << "unknown"; + if (*this == unknownNonNegative()) + OS << "unknown non-negative"; + if (*this == unknownMaybeNegative()) + OS << "unknown maybe-negative"; else if (*this == mapEmpty()) OS << "mapEmpty"; else if (*this == mapTombstone()) @@ -57,8 +59,8 @@ AAMDNodes AATags; VI->getAAMetadata(AATags); - return MemoryLocation(VI->getPointerOperand(), LocationSize::unknown(), - AATags); + return MemoryLocation(VI->getPointerOperand(), + LocationSize::unknownNonNegative(), AATags); } MemoryLocation MemoryLocation::get(const AtomicCmpXchgInst *CXI) { @@ -109,7 +111,7 @@ } MemoryLocation MemoryLocation::getForSource(const AnyMemTransferInst *MTI) { - auto Size = LocationSize::unknown(); + auto Size = LocationSize::unknownNonNegative(); if (ConstantInt *C = dyn_cast(MTI->getLength())) Size = LocationSize::precise(C->getValue().getZExtValue()); @@ -130,7 +132,7 @@ } MemoryLocation MemoryLocation::getForDest(const AnyMemIntrinsic *MI) { - auto Size = LocationSize::unknown(); + auto Size = LocationSize::unknownNonNegative(); if (ConstantInt *C = dyn_cast(MI->getLength())) Size = LocationSize::precise(C->getValue().getZExtValue()); @@ -269,6 +271,6 @@ } // FIXME: Handle memset_pattern4 and memset_pattern8 also. - return MemoryLocation(Call->getArgOperand(ArgIdx), LocationSize::unknown(), - AATags); + return MemoryLocation(Call->getArgOperand(ArgIdx), + LocationSize::unknownMaybeNegative(), AATags); } Index: llvm/lib/Analysis/MemorySSA.cpp =================================================================== --- llvm/lib/Analysis/MemorySSA.cpp +++ llvm/lib/Analysis/MemorySSA.cpp @@ -363,7 +363,8 @@ if (IntrinsicInst *II = dyn_cast(Inst)) { switch (II->getIntrinsicID()) { case Intrinsic::lifetime_end: { - MemoryLocation ArgLoc(II->getArgOperand(1), LocationSize::unknown()); + MemoryLocation ArgLoc = + MemoryLocation::getStartingFrom(II->getArgOperand(1)); return AA.alias(ArgLoc, Loc) == MustAlias; } default: Index: llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp =================================================================== --- llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp +++ llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp @@ -58,8 +58,7 @@ const Value *UB = GetUnderlyingObjCPtr(SB); if (UA != SA || UB != SB) { Result = AAResultBase::alias( - MemoryLocation(UA, LocationSize::unknown()), - MemoryLocation(UB, LocationSize::unknown()), AAQI); + MemoryLocation::getBasedOn(UA), MemoryLocation::getBasedOn(UB), AAQI); // We can't use MustAlias or PartialAlias results here because // GetUnderlyingObjCPtr may return an offsetted pointer value. if (Result == NoAlias) @@ -88,7 +87,7 @@ const Value *U = GetUnderlyingObjCPtr(S); if (U != S) return AAResultBase::pointsToConstantMemory( - MemoryLocation(U, LocationSize::unknown()), AAQI, OrLocal); + MemoryLocation::getBasedOn(U), AAQI, OrLocal); // If that failed, fail. We don't need to chain here, since that's covered // by the earlier precise query. Index: llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp =================================================================== --- llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp +++ llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp @@ -82,10 +82,12 @@ Value *BO = GetBaseValue(BS); if ((AO && AO != LocA.Ptr) || (BO && BO != LocB.Ptr)) if (alias(MemoryLocation(AO ? AO : LocA.Ptr, - AO ? LocationSize::unknown() : LocA.Size, + AO ? LocationSize::unknownMaybeNegative() + : LocA.Size, AO ? AAMDNodes() : LocA.AATags), MemoryLocation(BO ? BO : LocB.Ptr, - BO ? LocationSize::unknown() : LocB.Size, + BO ? LocationSize::unknownMaybeNegative() + : LocB.Size, BO ? AAMDNodes() : LocB.AATags), AAQI) == NoAlias) return NoAlias; Index: llvm/lib/CodeGen/ImplicitNullChecks.cpp =================================================================== --- llvm/lib/CodeGen/ImplicitNullChecks.cpp +++ llvm/lib/CodeGen/ImplicitNullChecks.cpp @@ -353,11 +353,11 @@ return AR_MayAlias; continue; } - llvm::AliasResult AAResult = - AA->alias(MemoryLocation(MMO1->getValue(), LocationSize::unknown(), - MMO1->getAAInfo()), - MemoryLocation(MMO2->getValue(), LocationSize::unknown(), - MMO2->getAAInfo())); + llvm::AliasResult AAResult = AA->alias( + MemoryLocation(MMO1->getValue(), LocationSize::unknownNonNegative(), + MMO1->getAAInfo()), + MemoryLocation(MMO2->getValue(), LocationSize::unknownNonNegative(), + MMO2->getAAInfo())); if (AAResult != NoAlias) return AR_MayAlias; } Index: llvm/lib/CodeGen/MachinePipeliner.cpp =================================================================== --- llvm/lib/CodeGen/MachinePipeliner.cpp +++ llvm/lib/CodeGen/MachinePipeliner.cpp @@ -802,11 +802,13 @@ SU.addPred(Dep); continue; } - AliasResult AAResult = AA->alias( - MemoryLocation(MMO1->getValue(), LocationSize::unknown(), - MMO1->getAAInfo()), - MemoryLocation(MMO2->getValue(), LocationSize::unknown(), - MMO2->getAAInfo())); + AliasResult AAResult = + AA->alias(MemoryLocation(MMO1->getValue(), + LocationSize::unknownNonNegative(), + MMO1->getAAInfo()), + MemoryLocation(MMO2->getValue(), + LocationSize::unknownNonNegative(), + MMO2->getAAInfo())); if (AAResult != NoAlias) { SDep Dep(Load, SDep::Barrier); Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4353,7 +4353,7 @@ // Do not serialize masked loads of constant memory with anything. MemoryLocation ML; if (VT.isScalableVector()) - ML = MemoryLocation(PtrOperand, LocationSize::unknown()); + ML = MemoryLocation::getStartingFrom(PtrOperand); else ML = MemoryLocation(PtrOperand, LocationSize::precise( DAG.getDataLayout().getTypeStoreSize(I.getType())), Index: llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp @@ -109,7 +109,7 @@ BasicBlock::iterator StartIt = (!L && (BB == Load->getParent())) ? BasicBlock::iterator(Load) : BB->end(); auto Q = MDR->getPointerDependencyFrom( - MemoryLocation(Ptr, LocationSize::unknown()), true, StartIt, BB, Load); + MemoryLocation::getBasedOn(Ptr), true, StartIt, BB, Load); if (Q.isClobber() || Q.isUnknown()) return true; } Index: llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp +++ llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp @@ -304,8 +304,7 @@ BasicBlock *BB = RI->getParent(); MemDepResult Q = MDA->getPointerDependencyFrom( - MemoryLocation(OutArg, LocationSize::unknown()), true, BB->end(), - BB, RI); + MemoryLocation::getBasedOn(OutArg), true, BB->end(), BB, RI); StoreInst *SI = nullptr; if (Q.isDef()) SI = dyn_cast(Q.getInst()); Index: llvm/lib/Target/ARM/ARMParallelDSP.cpp =================================================================== --- llvm/lib/Target/ARM/ARMParallelDSP.cpp +++ llvm/lib/Target/ARM/ARMParallelDSP.cpp @@ -374,7 +374,7 @@ DepMap RAWDeps; // Record any writes that may alias a load. - const auto Size = LocationSize::unknown(); + const auto Size = LocationSize::unknownMaybeNegative(); for (auto Write : Writes) { for (auto Read : Loads) { MemoryLocation ReadLoc = Index: llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp =================================================================== --- llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp +++ llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp @@ -1973,7 +1973,7 @@ // Get the location that may be stored across the loop. Since the access // is strided positively through memory, we say that the modified location // starts at the pointer and has infinite size. - LocationSize AccessSize = LocationSize::unknown(); + LocationSize AccessSize = LocationSize::unknownNonNegative(); // If the loop iterates a fixed number of times, we can refine the access // size to be exactly the size of the memset, which is (BECount+1)*StoreSize Index: llvm/lib/Transforms/IPO/FunctionAttrs.cpp =================================================================== --- llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -166,7 +166,7 @@ AAMDNodes AAInfo; I->getAAMetadata(AAInfo); - MemoryLocation Loc(Arg, LocationSize::unknown(), AAInfo); + MemoryLocation Loc(Arg, LocationSize::unknownMaybeNegative(), AAInfo); // Skip accesses to local or constant memory as they don't impact the // externally visible mod/ref behavior. Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp =================================================================== --- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -275,7 +275,7 @@ default: return MemoryLocation(); // Unhandled intrinsic. case Intrinsic::init_trampoline: - return MemoryLocation(II->getArgOperand(0), LocationSize::unknown()); + return MemoryLocation::getStartingFrom(II->getArgOperand(0)); case Intrinsic::masked_store: return MemoryLocation::getForArgument(II, 1, TLI); case Intrinsic::lifetime_end: { @@ -287,7 +287,7 @@ if (auto *CB = dyn_cast(Inst)) // All the supported TLI functions so far happen to have dest as their // first argument. - return MemoryLocation(CB->getArgOperand(0), LocationSize::unknown()); + return MemoryLocation::getStartingFrom(CB->getArgOperand(0)); return MemoryLocation(); } @@ -828,8 +828,7 @@ MapVector &ThrowableInst) { bool MadeChange = false; - MemoryLocation Loc = MemoryLocation(F->getOperand(0), - LocationSize::unknown()); + MemoryLocation Loc = MemoryLocation::getStartingFrom(F->getOperand(0)); SmallVector Blocks; Blocks.push_back(F->getParent()); @@ -1726,15 +1725,14 @@ case LibFunc_strncpy: case LibFunc_strcat: case LibFunc_strncat: - return {MemoryLocation(CB->getArgOperand(0), - LocationSize::unknown())}; + return {MemoryLocation::getStartingFrom(CB->getArgOperand(0))}; default: break; } } switch (CB->getIntrinsicID()) { case Intrinsic::init_trampoline: - return {MemoryLocation(CB->getArgOperand(0), LocationSize::unknown())}; + return {MemoryLocation::getStartingFrom(CB->getArgOperand(0))}; case Intrinsic::masked_store: return {MemoryLocation::getForArgument(CB, 1, TLI)}; default: @@ -1829,9 +1827,7 @@ if (auto *CB = dyn_cast(I)) { if (isFreeCall(I, &TLI)) - return {std::make_pair(MemoryLocation(CB->getArgOperand(0), - LocationSize::unknown()), - true)}; + return {{MemoryLocation::getStartingFrom(CB->getArgOperand(0)), true}}; } return None; Index: llvm/lib/Transforms/Scalar/LICM.cpp =================================================================== --- llvm/lib/Transforms/Scalar/LICM.cpp +++ llvm/lib/Transforms/Scalar/LICM.cpp @@ -1207,8 +1207,7 @@ bool Invalidated; if (CurAST) Invalidated = pointerInvalidatedByLoop( - MemoryLocation(Op, LocationSize::unknown(), AAMDNodes()), - CurAST, CurLoop, AA); + MemoryLocation::getBasedOn(Op), CurAST, CurLoop, AA); else Invalidated = pointerInvalidatedByLoopWithMSSA( MSSA, cast(MSSA->getMemoryAccess(CI)), CurLoop, Index: llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp =================================================================== --- llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -844,7 +844,7 @@ // Get the location that may be stored across the loop. Since the access is // strided positively through memory, we say that the modified location starts // at the pointer and has infinite size. - LocationSize AccessSize = LocationSize::unknown(); + LocationSize AccessSize = LocationSize::unknownNonNegative(); // If the loop iterates a fixed number of times, we can refine the access size // to be exactly the size of the memset, which is (BECount+1)*StoreSize Index: llvm/test/Analysis/AliasSet/argmemonly.ll =================================================================== --- llvm/test/Analysis/AliasSet/argmemonly.ll +++ llvm/test/Analysis/AliasSet/argmemonly.ll @@ -6,7 +6,7 @@ ; CHECK: Alias sets for function 'test_alloca_argmemonly': ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 3 pointer values. ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, LocationSize::precise(1)) -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref Pointers: (i8* %d, unknown), (i8* %s, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref Pointers: (i8* %d, unknown maybe-negative), (i8* %s, unknown maybe-negative) define void @test_alloca_argmemonly(i8* %s, i8* %d) { entry: %a = alloca i8, align 1 @@ -17,8 +17,8 @@ ; CHECK: Alias sets for function 'test_readonly_arg' ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values. -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown) -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Ref Pointers: (i8* %s, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown maybe-negative) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Ref Pointers: (i8* %s, unknown maybe-negative) define i8 @test_readonly_arg(i8* noalias %s, i8* noalias %d) { entry: call void @my_memcpy(i8* %d, i8* %s, i64 1) @@ -29,7 +29,7 @@ ; CHECK: Alias sets for function 'test_noalias_argmemonly': ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 3 pointer values. ; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, LocationSize::precise(1)) -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref Pointers: (i8* %d, unknown), (i8* %s, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref Pointers: (i8* %d, unknown maybe-negative), (i8* %s, unknown maybe-negative) define void @test_noalias_argmemonly(i8* noalias %a, i8* %s, i8* %d) { entry: store i8 1, i8* %a, align 1 @@ -39,8 +39,8 @@ ; CHECK: Alias sets for function 'test5': ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values. -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown) -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %b, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown maybe-negative) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %b, unknown maybe-negative) define void @test5(i8* noalias %a, i8* noalias %b) { entry: store i8 1, i8* %a, align 1 @@ -51,8 +51,8 @@ ; CHECK: Alias sets for function 'test_argcollapse': ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values. -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown) -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %b, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown maybe-negative) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %b, unknown maybe-negative) define void @test_argcollapse(i8* noalias %a, i8* noalias %b) { entry: store i8 1, i8* %a, align 1 @@ -63,8 +63,8 @@ ; CHECK: Alias sets for function 'test_memcpy1': ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values. -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %b, unknown) -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %b, unknown maybe-negative) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod/Ref Pointers: (i8* %a, unknown maybe-negative) define void @test_memcpy1(i8* noalias %a, i8* noalias %b) { entry: call void @my_memcpy(i8* %b, i8* %a, i64 1) @@ -74,7 +74,7 @@ ; CHECK: Alias sets for function 'test_memset1': ; CHECK-NEXT: Alias Set Tracker: 1 alias sets for 1 pointer values. -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown maybe-negative) define void @test_memset1() { entry: %a = alloca i8, align 1 @@ -84,7 +84,7 @@ ; CHECK: Alias sets for function 'test_memset2': ; CHECK-NEXT: Alias Set Tracker: 1 alias sets for 1 pointer values. -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown maybe-negative) define void @test_memset2(i8* %a) { entry: call void @my_memset(i8* %a, i8 0, i64 1) @@ -93,7 +93,7 @@ ; CHECK: Alias sets for function 'test_memset3': ; CHECK-NEXT: Alias Set Tracker: 1 alias sets for 2 pointer values. -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod Pointers: (i8* %a, unknown), (i8* %b, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod Pointers: (i8* %a, unknown maybe-negative), (i8* %b, unknown maybe-negative) define void @test_memset3(i8* %a, i8* %b) { entry: call void @my_memset(i8* %a, i8 0, i64 1) @@ -105,8 +105,8 @@ ; CHECK: Alias sets for function 'test_memset4': ; CHECK-NEXT: Alias Set Tracker: 2 alias sets for 2 pointer values. -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown) -; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %b, unknown) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, unknown maybe-negative) +; CHECK-NEXT: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %b, unknown maybe-negative) define void @test_memset4(i8* noalias %a, i8* noalias %b) { entry: call void @my_memset(i8* %a, i8 0, i64 1) Index: llvm/test/Analysis/AliasSet/memset.ll =================================================================== --- llvm/test/Analysis/AliasSet/memset.ll +++ llvm/test/Analysis/AliasSet/memset.ll @@ -14,7 +14,7 @@ ; CHECK: Alias sets for function 'test_unknown_size': ; CHECK: Alias Set Tracker: 1 alias sets for 1 pointer values. -; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown) +; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown non-negative) define void @test_unknown_size(i8* noalias %d, i64 %len) { entry: call void @llvm.memset.p0i8.i64(i8* align 1 %d, i8 0, i64 %len, i1 false) @@ -33,7 +33,7 @@ ; CHECK: Alias sets for function 'test_atomic_unknown_size': ; CHECK: Alias Set Tracker: 1 alias sets for 1 pointer values. -; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown) +; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown non-negative) define void @test_atomic_unknown_size(i8* noalias %d, i64 %len) { entry: call void @llvm.memset.element.unordered.atomic.p0i8.i32(i8* align 1 %d, i8 0, i64 %len, i32 1) Index: llvm/test/Analysis/AliasSet/memtransfer.ll =================================================================== --- llvm/test/Analysis/AliasSet/memtransfer.ll +++ llvm/test/Analysis/AliasSet/memtransfer.ll @@ -16,8 +16,8 @@ ; CHECK: Alias sets for function 'test_unknown_size': ; CHECK: Alias Set Tracker: 2 alias sets for 2 pointer values. -; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown) -; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Ref Pointers: (i8* %s, unknown) +; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %d, unknown non-negative) +; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Ref Pointers: (i8* %s, unknown non-negative) define void @test_unknown_size(i8* noalias %s, i8* noalias %d, i64 %len) { entry: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %d, i8* %s, i64 %len, i1 false) Index: llvm/test/Analysis/BasicAA/cs-cs.ll =================================================================== --- llvm/test/Analysis/BasicAA/cs-cs.ll +++ llvm/test/Analysis/BasicAA/cs-cs.ll @@ -273,9 +273,9 @@ ; CHECK-LABEL: Function: test8 ; CHECK: NoModRef: Ptr: i8* %p <-> call void @an_inaccessiblememonly_func() ; CHECK: NoModRef: Ptr: i8* %q <-> call void @an_inaccessiblememonly_func() -; CHECK: NoModRef: Ptr: i8* %p <-> call void @an_inaccessibleorargmemonly_func(i8* %q) +; CHECK: Both ModRef: Ptr: i8* %p <-> call void @an_inaccessibleorargmemonly_func(i8* %q) ; CHECK: Both ModRef (MustAlias): Ptr: i8* %q <-> call void @an_inaccessibleorargmemonly_func(i8* %q) -; CHECK: NoModRef: Ptr: i8* %p <-> call void @an_argmemonly_func(i8* %q) +; CHECK: Both ModRef: Ptr: i8* %p <-> call void @an_argmemonly_func(i8* %q) ; CHECK: Both ModRef (MustAlias): Ptr: i8* %q <-> call void @an_argmemonly_func(i8* %q) ; CHECK: Just Ref: call void @a_readonly_func(i8* %p) <-> call void @an_inaccessiblememonly_func() ; CHECK: Just Ref: call void @a_readonly_func(i8* %p) <-> call void @an_inaccessibleorargmemonly_func(i8* %q) @@ -368,9 +368,9 @@ ; CHECK: Just Ref: Ptr: i8* %q <-> call void @a_readonly_func(i8* %p) #9 [ "unknown"() ] ; CHECK: NoModRef: Ptr: i8* %p <-> call void @an_inaccessiblememonly_func() #10 [ "unknown"() ] ; CHECK: NoModRef: Ptr: i8* %q <-> call void @an_inaccessiblememonly_func() #10 [ "unknown"() ] -; CHECK: NoModRef: Ptr: i8* %p <-> call void @an_inaccessibleorargmemonly_func(i8* %q) #11 [ "unknown"() ] +; CHECK: Both ModRef: Ptr: i8* %p <-> call void @an_inaccessibleorargmemonly_func(i8* %q) #11 [ "unknown"() ] ; CHECK: Both ModRef (MustAlias): Ptr: i8* %q <-> call void @an_inaccessibleorargmemonly_func(i8* %q) #11 [ "unknown"() ] -; CHECK: NoModRef: Ptr: i8* %p <-> call void @an_argmemonly_func(i8* %q) #12 [ "unknown"() ] +; CHECK: Both ModRef: Ptr: i8* %p <-> call void @an_argmemonly_func(i8* %q) #12 [ "unknown"() ] ; CHECK: Both ModRef (MustAlias): Ptr: i8* %q <-> call void @an_argmemonly_func(i8* %q) #12 [ "unknown"() ] ; CHECK: Just Ref: call void @a_readonly_func(i8* %p) #9 [ "unknown"() ] <-> call void @an_inaccessiblememonly_func() #10 [ "unknown"() ] ; CHECK: Just Ref: call void @a_readonly_func(i8* %p) #9 [ "unknown"() ] <-> call void @an_inaccessibleorargmemonly_func(i8* %q) #11 [ "unknown"() ] Index: llvm/unittests/Analysis/AliasAnalysisTest.cpp =================================================================== --- llvm/unittests/Analysis/AliasAnalysisTest.cpp +++ llvm/unittests/Analysis/AliasAnalysisTest.cpp @@ -55,8 +55,8 @@ for (Value *P1 : Pointers) for (Value *P2 : Pointers) - (void)AA.alias(P1, LocationSize::unknown(), P2, - LocationSize::unknown()); + (void)AA.alias(P1, LocationSize::unknownMaybeNegative(), P2, + LocationSize::unknownMaybeNegative()); return false; } Index: llvm/unittests/Analysis/MemorySSATest.cpp =================================================================== --- llvm/unittests/Analysis/MemorySSATest.cpp +++ llvm/unittests/Analysis/MemorySSATest.cpp @@ -1277,7 +1277,7 @@ MemoryAccess *LifetimeStartClobber = MSSA.getWalker()->getClobberingMemoryAccess( - LifetimeStartAccess, MemoryLocation(Foo, LocationSize::unknown())); + LifetimeStartAccess, MemoryLocation::getStartingFrom(Foo)); EXPECT_EQ(LifetimeStartClobber, LifetimeStartAccess); } Index: polly/lib/Analysis/ScopDetection.cpp =================================================================== --- polly/lib/Analysis/ScopDetection.cpp +++ polly/lib/Analysis/ScopDetection.cpp @@ -1129,7 +1129,8 @@ AAMDNodes AATags; Inst->getAAMetadata(AATags); AliasSet &AS = Context.AST.getAliasSetFor( - MemoryLocation(BP->getValue(), LocationSize::unknown(), AATags)); + MemoryLocation(BP->getValue(), LocationSize::unknownMaybeNegative(), + AATags)); if (!AS.isMustAlias()) { if (PollyUseRuntimeAliasChecks) {