[llvm] r370128 - [NFC] Assert preconditions and merge all users into one codepath in Loads.cpp
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 27 16:36:32 PDT 2019
Author: reames
Date: Tue Aug 27 16:36:31 2019
New Revision: 370128
URL: http://llvm.org/viewvc/llvm-project?rev=370128&view=rev
Log:
[NFC] Assert preconditions and merge all users into one codepath in Loads.cpp
Modified:
llvm/trunk/lib/Analysis/Loads.cpp
Modified: llvm/trunk/lib/Analysis/Loads.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Loads.cpp?rev=370128&r1=370127&r2=370128&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Loads.cpp (original)
+++ llvm/trunk/lib/Analysis/Loads.cpp Tue Aug 27 16:36:31 2019
@@ -118,6 +118,12 @@ bool llvm::isDereferenceableAndAlignedPo
const DataLayout &DL,
const Instruction *CtxI,
const DominatorTree *DT) {
+ assert(Align != 0 && "expected explicitly set alignment");
+ // Note: At the moment, Size can be zero. This ends up being interpreted as
+ // a query of whether [Base, V] is dereferenceable and V is aligned (since
+ // that's what the implementation happened to do). It's unclear if this is
+ // the desired semantic, but at least SelectionDAG does exercise this case.
+
SmallPtrSet<const Value *, 32> Visited;
return ::isDereferenceableAndAlignedPointer(V, Align, Size, DL, CtxI, DT,
Visited);
@@ -139,12 +145,11 @@ bool llvm::isDereferenceableAndAlignedPo
if (!Ty->isSized())
return false;
-
- SmallPtrSet<const Value *, 32> Visited;
- return ::isDereferenceableAndAlignedPointer(
- V, Align,
- APInt(DL.getIndexTypeSizeInBits(V->getType()), DL.getTypeStoreSize(Ty)),
- DL, CtxI, DT, Visited);
+
+ APInt AccessSize(DL.getIndexTypeSizeInBits(V->getType()),
+ DL.getTypeStoreSize(Ty));
+ return isDereferenceableAndAlignedPointer(V, Align, AccessSize,
+ DL, CtxI, DT);
}
bool llvm::isDereferenceablePointer(const Value *V, Type *Ty,
More information about the llvm-commits
mailing list