llvm.org GIT mirror llvm / ea46abe
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344186 91177308-0d34-0410-b5e6-96231b3b80d8 George Burgess IV 11 months ago
16 changed file(s) with 48 addition(s) and 50 deletion(s). Raw diff Collapse all Expand all
334334
335335 /// A convenience wrapper around the primary \c alias interface.
336336 AliasResult alias(const Value *V1, const Value *V2) {
337 return alias(V1, MemoryLocation::UnknownSize, V2,
338 MemoryLocation::UnknownSize);
337 return alias(V1, LocationSize::unknown(), V2, LocationSize::unknown());
339338 }
340339
341340 /// A trivial helper function to check to see if the specified pointers are
303303 /// The maximum size of the dereferences of the pointer.
304304 ///
305305 /// May be UnknownSize if the sizes are unknown.
306 LocationSize Size = MemoryLocation::UnknownSize;
306 LocationSize Size = LocationSize::unknown();
307307 /// The AA tags associated with dereferences of the pointer.
308308 ///
309309 /// The members may be null if there are no tags or conflicting tags.
238238 }
239239
240240 explicit MemoryLocation(const Value *Ptr = nullptr,
241 LocationSize Size = UnknownSize,
241 LocationSize Size = LocationSize::unknown(),
242242 const AAMDNodes &AATags = AAMDNodes())
243243 : Ptr(Ptr), Size(Size), AATags(AATags) {}
244244
648648 for (iterator I = begin(), E = end(); I != E; ++I) {
649649 if (I != begin()) OS << ", ";
650650 I.getPointer()->printAsOperand(OS << "(");
651 if (I.getSize() == MemoryLocation::UnknownSize)
651 if (I.getSize() == LocationSize::unknown())
652652 OS << ", unknown)";
653653 else
654654 OS << ", " << I.getSize() << ")";
10181018
10191019 // If we don't know the size of the accesses through both GEPs, we can't
10201020 // determine whether the struct fields accessed can't alias.
1021 if (MaybeV1Size == MemoryLocation::UnknownSize ||
1022 MaybeV2Size == MemoryLocation::UnknownSize)
1021 if (MaybeV1Size == LocationSize::unknown() ||
1022 MaybeV2Size == LocationSize::unknown())
10231023 return MayAlias;
10241024
10251025 const uint64_t V1Size = MaybeV1Size.getValue();
11831183 const DecomposedGEP &DecompGEP, const DecomposedGEP &DecompObject,
11841184 LocationSize MaybeObjectAccessSize) {
11851185 // If the object access size is unknown, or the GEP isn't inbounds, bail.
1186 if (MaybeObjectAccessSize == MemoryLocation::UnknownSize ||
1187 !GEPOp->isInBounds())
1186 if (MaybeObjectAccessSize == LocationSize::unknown() || !GEPOp->isInBounds())
11881187 return false;
11891188
11901189 const uint64_t ObjectAccessSize = MaybeObjectAccessSize.getValue();
12531252 return NoAlias;
12541253 // Do the base pointers alias?
12551254 AliasResult BaseAlias =
1256 aliasCheck(UnderlyingV1, MemoryLocation::UnknownSize, AAMDNodes(),
1257 UnderlyingV2, MemoryLocation::UnknownSize, AAMDNodes());
1255 aliasCheck(UnderlyingV1, LocationSize::unknown(), AAMDNodes(),
1256 UnderlyingV2, LocationSize::unknown(), AAMDNodes());
12581257
12591258 // Check for geps of non-aliasing underlying pointers where the offsets are
12601259 // identical.
13131312 // pointer, we know they cannot alias.
13141313
13151314 // If both accesses are unknown size, we can't do anything useful here.
1316 if (V1Size == MemoryLocation::UnknownSize &&
1317 V2Size == MemoryLocation::UnknownSize)
1315 if (V1Size == LocationSize::unknown() && V2Size == LocationSize::unknown())
13181316 return MayAlias;
13191317
1320 AliasResult R = aliasCheck(UnderlyingV1, MemoryLocation::UnknownSize,
1321 AAMDNodes(), V2, MemoryLocation::UnknownSize,
1322 V2AAInfo, nullptr, UnderlyingV2);
1318 AliasResult R =
1319 aliasCheck(UnderlyingV1, LocationSize::unknown(), AAMDNodes(), V2,
1320 LocationSize::unknown(), V2AAInfo, nullptr, UnderlyingV2);
13231321 if (R != MustAlias) {
13241322 // If V2 may alias GEP base pointer, conservatively returns MayAlias.
13251323 // If V2 is known not to alias GEP base pointer, then the two values
13501348 // greater, we know they do not overlap.
13511349 if (GEP1BaseOffset != 0 && DecompGEP1.VarIndices.empty()) {
13521350 if (GEP1BaseOffset >= 0) {
1353 if (V2Size != MemoryLocation::UnknownSize) {
1351 if (V2Size != LocationSize::unknown()) {
13541352 if ((uint64_t)GEP1BaseOffset < V2Size.getValue())
13551353 return PartialAlias;
13561354 return NoAlias;
13641362 // GEP1 V2
13651363 // We need to know that V2Size is not unknown, otherwise we might have
13661364 // stripped a gep with negative index ('gep , -1, ...).
1367 if (V1Size != MemoryLocation::UnknownSize &&
1368 V2Size != MemoryLocation::UnknownSize) {
1365 if (V1Size != LocationSize::unknown() &&
1366 V2Size != LocationSize::unknown()) {
13691367 if (-(uint64_t)GEP1BaseOffset < V1Size.getValue())
13701368 return PartialAlias;
13711369 return NoAlias;
14151413 // mod Modulo. Check whether that difference guarantees that the
14161414 // two locations do not alias.
14171415 uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1);
1418 if (V1Size != MemoryLocation::UnknownSize &&
1419 V2Size != MemoryLocation::UnknownSize &&
1420 ModOffset >= V2Size.getValue() &&
1416 if (V1Size != LocationSize::unknown() &&
1417 V2Size != LocationSize::unknown() && ModOffset >= V2Size.getValue() &&
14211418 V1Size.getValue() <= Modulo - ModOffset)
14221419 return NoAlias;
14231420
14251422 // If GEP1BasePtr > V2 (GEP1BaseOffset > 0) then we know the pointers
14261423 // don't alias if V2Size can fit in the gap between V2 and GEP1BasePtr.
14271424 if (AllPositive && GEP1BaseOffset > 0 &&
1428 V2Size != MemoryLocation::UnknownSize &&
1425 V2Size != LocationSize::unknown() &&
14291426 V2Size.getValue() <= (uint64_t)GEP1BaseOffset)
14301427 return NoAlias;
14311428
16061603 // unknown to represent all the possible values the GEP could advance the
16071604 // pointer to.
16081605 if (isRecursive)
1609 PNSize = MemoryLocation::UnknownSize;
1606 PNSize = LocationSize::unknown();
16101607
16111608 AliasResult Alias =
16121609 aliasCheck(V2, V2Size, V2AAInfo, V1Srcs[0],
18631860 const SmallVectorImpl &VarIndices,
18641861 LocationSize MaybeV1Size, LocationSize MaybeV2Size, int64_t BaseOffset,
18651862 AssumptionCache *AC, DominatorTree *DT) {
1866 if (VarIndices.size() != 2 || MaybeV1Size == MemoryLocation::UnknownSize ||
1867 MaybeV2Size == MemoryLocation::UnknownSize)
1863 if (VarIndices.size() != 2 || MaybeV1Size == LocationSize::unknown() ||
1864 MaybeV2Size == LocationSize::unknown())
18681865 return false;
18691866
18701867 const uint64_t V1Size = MaybeV1Size.getValue();
555555 OffsetValue{RHS, 0}, Comparator);
556556
557557 if (RangePair.first != RangePair.second) {
558 // Be conservative about UnknownSize
559 if (MaybeLHSSize == MemoryLocation::UnknownSize ||
560 MaybeRHSSize == MemoryLocation::UnknownSize)
558 // Be conservative about unknown sizes
559 if (MaybeLHSSize == LocationSize::unknown() ||
560 MaybeRHSSize == LocationSize::unknown())
561561 return true;
562562
563563 const uint64_t LHSSize = MaybeLHSSize.getValue();
632632 const MemoryLocation &LocB) {
633633 // Check the original locations (minus size) for noalias, which can happen for
634634 // tbaa, incompatible underlying object locations, etc.
635 MemoryLocation LocAS(LocA.Ptr, MemoryLocation::UnknownSize, LocA.AATags);
636 MemoryLocation LocBS(LocB.Ptr, MemoryLocation::UnknownSize, LocB.AATags);
635 MemoryLocation LocAS(LocA.Ptr, LocationSize::unknown(), LocA.AATags);
636 MemoryLocation LocBS(LocB.Ptr, LocationSize::unknown(), LocB.AATags);
637637 if (AA->alias(LocAS, LocBS) == NoAlias)
638638 return NoAlias;
639639
508508 /// Register a load and whether it is only read from.
509509 void addLoad(MemoryLocation &Loc, bool IsReadOnly) {
510510 Value *Ptr = const_cast(Loc.Ptr);
511 AST.add(Ptr, MemoryLocation::UnknownSize, Loc.AATags);
511 AST.add(Ptr, LocationSize::unknown(), Loc.AATags);
512512 Accesses.insert(MemAccessInfo(Ptr, false));
513513 if (IsReadOnly)
514514 ReadOnlyPtr.insert(Ptr);
517517 /// Register a store.
518518 void addStore(MemoryLocation &Loc) {
519519 Value *Ptr = const_cast(Loc.Ptr);
520 AST.add(Ptr, MemoryLocation::UnknownSize, Loc.AATags);
520 AST.add(Ptr, LocationSize::unknown(), Loc.AATags);
521521 Accesses.insert(MemAccessInfo(Ptr, true));
522522 }
523523
5454 AAMDNodes AATags;
5555 VI->getAAMetadata(AATags);
5656
57 return MemoryLocation(VI->getPointerOperand(), UnknownSize, AATags);
57 return MemoryLocation(VI->getPointerOperand(), LocationSize::unknown(),
58 AATags);
5859 }
5960
6061 MemoryLocation MemoryLocation::get(const AtomicCmpXchgInst *CXI) {
8687 }
8788
8889 MemoryLocation MemoryLocation::getForSource(const AnyMemTransferInst *MTI) {
89 uint64_t Size = UnknownSize;
90 uint64_t Size = MemoryLocation::UnknownSize;
9091 if (ConstantInt *C = dyn_cast(MTI->getLength()))
9192 Size = C->getValue().getZExtValue();
9293
107108 }
108109
109110 MemoryLocation MemoryLocation::getForDest(const AnyMemIntrinsic *MI) {
110 uint64_t Size = UnknownSize;
111 uint64_t Size = MemoryLocation::UnknownSize;
111112 if (ConstantInt *C = dyn_cast(MI->getLength()))
112113 Size = C->getValue().getZExtValue();
113114
188189 }
189190 // FIXME: Handle memset_pattern4 and memset_pattern8 also.
190191
191 return MemoryLocation(CS.getArgument(ArgIdx), UnknownSize, AATags);
192 return MemoryLocation(CS.getArgument(ArgIdx), LocationSize::unknown(),
193 AATags);
192194 }
343343 return AR_MayAlias;
344344 continue;
345345 }
346 llvm::AliasResult AAResult = AA->alias(
347 MemoryLocation(MMO1->getValue(), MemoryLocation::UnknownSize,
348 MMO1->getAAInfo()),
349 MemoryLocation(MMO2->getValue(), MemoryLocation::UnknownSize,
350 MMO2->getAAInfo()));
346 llvm::AliasResult AAResult =
347 AA->alias(MemoryLocation(MMO1->getValue(), LocationSize::unknown(),
348 MMO1->getAAInfo()),
349 MemoryLocation(MMO2->getValue(), LocationSize::unknown(),
350 MMO2->getAAInfo()));
351351 if (AAResult != NoAlias)
352352 return AR_MayAlias;
353353 }
11351135 continue;
11361136 }
11371137 AliasResult AAResult = AA->alias(
1138 MemoryLocation(MMO1->getValue(), MemoryLocation::UnknownSize,
1138 MemoryLocation(MMO1->getValue(), LocationSize::unknown(),
11391139 MMO1->getAAInfo()),
1140 MemoryLocation(MMO2->getValue(), MemoryLocation::UnknownSize,
1140 MemoryLocation(MMO2->getValue(), LocationSize::unknown(),
11411141 MMO2->getAAInfo()));
11421142
11431143 if (AAResult != NoAlias) {
7070 virtual ~OpChain() = default;
7171
7272 void SetMemoryLocations() {
73 const auto Size = MemoryLocation::UnknownSize;
73 const auto Size = LocationSize::unknown();
7474 for (auto *V : AllValues) {
7575 if (auto *I = dyn_cast(V)) {
7676 if (I->mayWriteToMemory())
19691969 // Get the location that may be stored across the loop. Since the access
19701970 // is strided positively through memory, we say that the modified location
19711971 // starts at the pointer and has infinite size.
1972 LocationSize AccessSize = MemoryLocation::UnknownSize;
1972 LocationSize AccessSize = LocationSize::unknown();
19731973
19741974 // If the loop iterates a fixed number of times, we can refine the access
19751975 // size to be exactly the size of the memset, which is (BECount+1)*StoreSize
164164
165165 AAMDNodes AAInfo;
166166 I->getAAMetadata(AAInfo);
167 MemoryLocation Loc(Arg, MemoryLocation::UnknownSize, AAInfo);
167 MemoryLocation Loc(Arg, LocationSize::unknown(), AAInfo);
168168
169169 // Skip accesses to local or constant memory as they don't impact the
170170 // externally visible mod/ref behavior.
692692 for (Value *Op : CI->arg_operands())
693693 if (Op->getType()->isPointerTy() &&
694694 pointerInvalidatedByLoop(
695 MemoryLocation(Op, MemoryLocation::UnknownSize, AAMDNodes()),
695 MemoryLocation(Op, LocationSize::unknown(), AAMDNodes()),
696696 CurAST, CurLoop, AA))
697697 return false;
698698 return true;
5454
5555 for (Value *P1 : Pointers)
5656 for (Value *P2 : Pointers)
57 (void)AA.alias(P1, MemoryLocation::UnknownSize, P2,
58 MemoryLocation::UnknownSize);
57 (void)AA.alias(P1, LocationSize::unknown(), P2,
58 LocationSize::unknown());
5959
6060 return false;
6161 }