summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2019-08-27 23:36:31 +0000
committerPhilip Reames <listmail@philipreames.com>2019-08-27 23:36:31 +0000
commit93a26ec98d345ccbad5e57e72e213d29cf8efaf1 (patch)
treecb29be7b0b22e0a7ef3923509591dc188301adcf /llvm/lib/Analysis/Loads.cpp
parent92ed86d239cdd6ed97dae3084f6537088da88677 (diff)
downloadbcm5719-llvm-93a26ec98d345ccbad5e57e72e213d29cf8efaf1.tar.gz
bcm5719-llvm-93a26ec98d345ccbad5e57e72e213d29cf8efaf1.zip
[NFC] Assert preconditions and merge all users into one codepath in Loads.cpp
llvm-svn: 370128
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r--llvm/lib/Analysis/Loads.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index a40f8dd1597..e74df9c69d7 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -118,6 +118,12 @@ bool llvm::isDereferenceableAndAlignedPointer(const Value *V, unsigned Align,
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::isDereferenceableAndAlignedPointer(const Value *V, Type *Ty,
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,
OpenPOWER on IntegriCloud