Replace most users of UnknownSize with LocationSize::unknown(); NFC

Moving away from UnknownSize is part of the effort to migrate us to
LocationSizes (e.g. the cleanup promised in D44748).

This doesn't entirely remove all of the uses of UnknownSize; some uses
require tweaks to assume that UnknownSize isn't just some kind of int.
This patch is intended to just be a trivial replacement for all places
where LocationSize::unknown() will Just Work.

llvm-svn: 344186
This commit is contained in:
George Burgess IV 2018-10-10 21:28:44 +00:00
parent fdb732b56c
commit 6ef8002c2c
16 changed files with 48 additions and 50 deletions

View File

@ -335,8 +335,7 @@ public:
/// A convenience wrapper around the primary \c alias interface.
AliasResult alias(const Value *V1, const Value *V2) {
return alias(V1, MemoryLocation::UnknownSize, V2,
MemoryLocation::UnknownSize);
return alias(V1, LocationSize::unknown(), V2, LocationSize::unknown());
}
/// A trivial helper function to check to see if the specified pointers are

View File

@ -304,7 +304,7 @@ private:
/// The maximum size of the dereferences of the pointer.
///
/// May be UnknownSize if the sizes are unknown.
LocationSize Size = MemoryLocation::UnknownSize;
LocationSize Size = LocationSize::unknown();
/// The AA tags associated with dereferences of the pointer.
///
/// The members may be null if there are no tags or conflicting tags.

View File

@ -239,7 +239,7 @@ public:
}
explicit MemoryLocation(const Value *Ptr = nullptr,
LocationSize Size = UnknownSize,
LocationSize Size = LocationSize::unknown(),
const AAMDNodes &AATags = AAMDNodes())
: Ptr(Ptr), Size(Size), AATags(AATags) {}

View File

@ -649,7 +649,7 @@ void AliasSet::print(raw_ostream &OS) const {
for (iterator I = begin(), E = end(); I != E; ++I) {
if (I != begin()) OS << ", ";
I.getPointer()->printAsOperand(OS << "(");
if (I.getSize() == MemoryLocation::UnknownSize)
if (I.getSize() == LocationSize::unknown())
OS << ", unknown)";
else
OS << ", " << I.getSize() << ")";

View File

@ -1019,8 +1019,8 @@ static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
// If we don't know the size of the accesses through both GEPs, we can't
// determine whether the struct fields accessed can't alias.
if (MaybeV1Size == MemoryLocation::UnknownSize ||
MaybeV2Size == MemoryLocation::UnknownSize)
if (MaybeV1Size == LocationSize::unknown() ||
MaybeV2Size == LocationSize::unknown())
return MayAlias;
const uint64_t V1Size = MaybeV1Size.getValue();
@ -1184,8 +1184,7 @@ bool BasicAAResult::isGEPBaseAtNegativeOffset(const GEPOperator *GEPOp,
const DecomposedGEP &DecompGEP, const DecomposedGEP &DecompObject,
LocationSize MaybeObjectAccessSize) {
// If the object access size is unknown, or the GEP isn't inbounds, bail.
if (MaybeObjectAccessSize == MemoryLocation::UnknownSize ||
!GEPOp->isInBounds())
if (MaybeObjectAccessSize == LocationSize::unknown() || !GEPOp->isInBounds())
return false;
const uint64_t ObjectAccessSize = MaybeObjectAccessSize.getValue();
@ -1254,8 +1253,8 @@ BasicAAResult::aliasGEP(const GEPOperator *GEP1, LocationSize V1Size,
return NoAlias;
// Do the base pointers alias?
AliasResult BaseAlias =
aliasCheck(UnderlyingV1, MemoryLocation::UnknownSize, AAMDNodes(),
UnderlyingV2, MemoryLocation::UnknownSize, AAMDNodes());
aliasCheck(UnderlyingV1, LocationSize::unknown(), AAMDNodes(),
UnderlyingV2, LocationSize::unknown(), AAMDNodes());
// Check for geps of non-aliasing underlying pointers where the offsets are
// identical.
@ -1314,13 +1313,12 @@ BasicAAResult::aliasGEP(const GEPOperator *GEP1, LocationSize V1Size,
// pointer, we know they cannot alias.
// If both accesses are unknown size, we can't do anything useful here.
if (V1Size == MemoryLocation::UnknownSize &&
V2Size == MemoryLocation::UnknownSize)
if (V1Size == LocationSize::unknown() && V2Size == LocationSize::unknown())
return MayAlias;
AliasResult R = aliasCheck(UnderlyingV1, MemoryLocation::UnknownSize,
AAMDNodes(), V2, MemoryLocation::UnknownSize,
V2AAInfo, nullptr, UnderlyingV2);
AliasResult R =
aliasCheck(UnderlyingV1, LocationSize::unknown(), AAMDNodes(), V2,
LocationSize::unknown(), V2AAInfo, 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
@ -1351,7 +1349,7 @@ BasicAAResult::aliasGEP(const GEPOperator *GEP1, LocationSize V1Size,
// greater, we know they do not overlap.
if (GEP1BaseOffset != 0 && DecompGEP1.VarIndices.empty()) {
if (GEP1BaseOffset >= 0) {
if (V2Size != MemoryLocation::UnknownSize) {
if (V2Size != LocationSize::unknown()) {
if ((uint64_t)GEP1BaseOffset < V2Size.getValue())
return PartialAlias;
return NoAlias;
@ -1365,8 +1363,8 @@ BasicAAResult::aliasGEP(const GEPOperator *GEP1, LocationSize V1Size,
// GEP1 V2
// We need to know that V2Size is not unknown, otherwise we might have
// stripped a gep with negative index ('gep <ptr>, -1, ...).
if (V1Size != MemoryLocation::UnknownSize &&
V2Size != MemoryLocation::UnknownSize) {
if (V1Size != LocationSize::unknown() &&
V2Size != LocationSize::unknown()) {
if (-(uint64_t)GEP1BaseOffset < V1Size.getValue())
return PartialAlias;
return NoAlias;
@ -1416,9 +1414,8 @@ BasicAAResult::aliasGEP(const GEPOperator *GEP1, LocationSize V1Size,
// mod Modulo. Check whether that difference guarantees that the
// two locations do not alias.
uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1);
if (V1Size != MemoryLocation::UnknownSize &&
V2Size != MemoryLocation::UnknownSize &&
ModOffset >= V2Size.getValue() &&
if (V1Size != LocationSize::unknown() &&
V2Size != LocationSize::unknown() && ModOffset >= V2Size.getValue() &&
V1Size.getValue() <= Modulo - ModOffset)
return NoAlias;
@ -1426,7 +1423,7 @@ BasicAAResult::aliasGEP(const GEPOperator *GEP1, LocationSize V1Size,
// If GEP1BasePtr > V2 (GEP1BaseOffset > 0) then we know the pointers
// don't alias if V2Size can fit in the gap between V2 and GEP1BasePtr.
if (AllPositive && GEP1BaseOffset > 0 &&
V2Size != MemoryLocation::UnknownSize &&
V2Size != LocationSize::unknown() &&
V2Size.getValue() <= (uint64_t)GEP1BaseOffset)
return NoAlias;
@ -1607,7 +1604,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
// unknown to represent all the possible values the GEP could advance the
// pointer to.
if (isRecursive)
PNSize = MemoryLocation::UnknownSize;
PNSize = LocationSize::unknown();
AliasResult Alias =
aliasCheck(V2, V2Size, V2AAInfo, V1Srcs[0],
@ -1864,8 +1861,8 @@ bool BasicAAResult::constantOffsetHeuristic(
const SmallVectorImpl<VariableGEPIndex> &VarIndices,
LocationSize MaybeV1Size, LocationSize MaybeV2Size, int64_t BaseOffset,
AssumptionCache *AC, DominatorTree *DT) {
if (VarIndices.size() != 2 || MaybeV1Size == MemoryLocation::UnknownSize ||
MaybeV2Size == MemoryLocation::UnknownSize)
if (VarIndices.size() != 2 || MaybeV1Size == LocationSize::unknown() ||
MaybeV2Size == LocationSize::unknown())
return false;
const uint64_t V1Size = MaybeV1Size.getValue();

View File

@ -556,9 +556,9 @@ bool CFLAndersAAResult::FunctionInfo::mayAlias(
OffsetValue{RHS, 0}, Comparator);
if (RangePair.first != RangePair.second) {
// Be conservative about UnknownSize
if (MaybeLHSSize == MemoryLocation::UnknownSize ||
MaybeRHSSize == MemoryLocation::UnknownSize)
// Be conservative about unknown sizes
if (MaybeLHSSize == LocationSize::unknown() ||
MaybeRHSSize == LocationSize::unknown())
return true;
const uint64_t LHSSize = MaybeLHSSize.getValue();

View File

@ -633,8 +633,8 @@ static AliasResult underlyingObjectsAlias(AliasAnalysis *AA,
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, MemoryLocation::UnknownSize, LocA.AATags);
MemoryLocation LocBS(LocB.Ptr, MemoryLocation::UnknownSize, LocB.AATags);
MemoryLocation LocAS(LocA.Ptr, LocationSize::unknown(), LocA.AATags);
MemoryLocation LocBS(LocB.Ptr, LocationSize::unknown(), LocB.AATags);
if (AA->alias(LocAS, LocBS) == NoAlias)
return NoAlias;

View File

@ -509,7 +509,7 @@ public:
/// Register a load and whether it is only read from.
void addLoad(MemoryLocation &Loc, bool IsReadOnly) {
Value *Ptr = const_cast<Value*>(Loc.Ptr);
AST.add(Ptr, MemoryLocation::UnknownSize, Loc.AATags);
AST.add(Ptr, LocationSize::unknown(), Loc.AATags);
Accesses.insert(MemAccessInfo(Ptr, false));
if (IsReadOnly)
ReadOnlyPtr.insert(Ptr);
@ -518,7 +518,7 @@ public:
/// Register a store.
void addStore(MemoryLocation &Loc) {
Value *Ptr = const_cast<Value*>(Loc.Ptr);
AST.add(Ptr, MemoryLocation::UnknownSize, Loc.AATags);
AST.add(Ptr, LocationSize::unknown(), Loc.AATags);
Accesses.insert(MemAccessInfo(Ptr, true));
}

View File

@ -55,7 +55,8 @@ MemoryLocation MemoryLocation::get(const VAArgInst *VI) {
AAMDNodes AATags;
VI->getAAMetadata(AATags);
return MemoryLocation(VI->getPointerOperand(), UnknownSize, AATags);
return MemoryLocation(VI->getPointerOperand(), LocationSize::unknown(),
AATags);
}
MemoryLocation MemoryLocation::get(const AtomicCmpXchgInst *CXI) {
@ -87,7 +88,7 @@ MemoryLocation MemoryLocation::getForSource(const AtomicMemTransferInst *MTI) {
}
MemoryLocation MemoryLocation::getForSource(const AnyMemTransferInst *MTI) {
uint64_t Size = UnknownSize;
uint64_t Size = MemoryLocation::UnknownSize;
if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
Size = C->getValue().getZExtValue();
@ -108,7 +109,7 @@ MemoryLocation MemoryLocation::getForDest(const AtomicMemIntrinsic *MI) {
}
MemoryLocation MemoryLocation::getForDest(const AnyMemIntrinsic *MI) {
uint64_t Size = UnknownSize;
uint64_t Size = MemoryLocation::UnknownSize;
if (ConstantInt *C = dyn_cast<ConstantInt>(MI->getLength()))
Size = C->getValue().getZExtValue();
@ -189,5 +190,6 @@ MemoryLocation MemoryLocation::getForArgument(ImmutableCallSite CS,
}
// FIXME: Handle memset_pattern4 and memset_pattern8 also.
return MemoryLocation(CS.getArgument(ArgIdx), UnknownSize, AATags);
return MemoryLocation(CS.getArgument(ArgIdx), LocationSize::unknown(),
AATags);
}

View File

@ -344,11 +344,11 @@ ImplicitNullChecks::areMemoryOpsAliased(MachineInstr &MI,
return AR_MayAlias;
continue;
}
llvm::AliasResult AAResult = AA->alias(
MemoryLocation(MMO1->getValue(), MemoryLocation::UnknownSize,
MMO1->getAAInfo()),
MemoryLocation(MMO2->getValue(), MemoryLocation::UnknownSize,
MMO2->getAAInfo()));
llvm::AliasResult AAResult =
AA->alias(MemoryLocation(MMO1->getValue(), LocationSize::unknown(),
MMO1->getAAInfo()),
MemoryLocation(MMO2->getValue(), LocationSize::unknown(),
MMO2->getAAInfo()));
if (AAResult != NoAlias)
return AR_MayAlias;
}

View File

@ -1136,9 +1136,9 @@ void SwingSchedulerDAG::addLoopCarriedDependences(AliasAnalysis *AA) {
continue;
}
AliasResult AAResult = AA->alias(
MemoryLocation(MMO1->getValue(), MemoryLocation::UnknownSize,
MemoryLocation(MMO1->getValue(), LocationSize::unknown(),
MMO1->getAAInfo()),
MemoryLocation(MMO2->getValue(), MemoryLocation::UnknownSize,
MemoryLocation(MMO2->getValue(), LocationSize::unknown(),
MMO2->getAAInfo()));
if (AAResult != NoAlias) {

View File

@ -71,7 +71,7 @@ namespace {
virtual ~OpChain() = default;
void SetMemoryLocations() {
const auto Size = MemoryLocation::UnknownSize;
const auto Size = LocationSize::unknown();
for (auto *V : AllValues) {
if (auto *I = dyn_cast<Instruction>(V)) {
if (I->mayWriteToMemory())

View File

@ -1970,7 +1970,7 @@ mayLoopAccessLocation(Value *Ptr, ModRefInfo Access, Loop *L,
// 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 = MemoryLocation::UnknownSize;
LocationSize AccessSize = LocationSize::unknown();
// 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

View File

@ -165,7 +165,7 @@ static MemoryAccessKind checkFunctionMemoryAccess(Function &F, bool ThisBody,
AAMDNodes AAInfo;
I->getAAMetadata(AAInfo);
MemoryLocation Loc(Arg, MemoryLocation::UnknownSize, AAInfo);
MemoryLocation Loc(Arg, LocationSize::unknown(), AAInfo);
// Skip accesses to local or constant memory as they don't impact the
// externally visible mod/ref behavior.

View File

@ -693,7 +693,7 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
for (Value *Op : CI->arg_operands())
if (Op->getType()->isPointerTy() &&
pointerInvalidatedByLoop(
MemoryLocation(Op, MemoryLocation::UnknownSize, AAMDNodes()),
MemoryLocation(Op, LocationSize::unknown(), AAMDNodes()),
CurAST, CurLoop, AA))
return false;
return true;

View File

@ -55,8 +55,8 @@ struct AATestPass : FunctionPass {
for (Value *P1 : Pointers)
for (Value *P2 : Pointers)
(void)AA.alias(P1, MemoryLocation::UnknownSize, P2,
MemoryLocation::UnknownSize);
(void)AA.alias(P1, LocationSize::unknown(), P2,
LocationSize::unknown());
return false;
}