From: Philip Reames Date: Tue, 27 Aug 2019 23:36:31 +0000 (+0000) Subject: [NFC] Assert preconditions and merge all users into one codepath in Loads.cpp X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3628d757f7d18adf96bc4c2175bedb451c9d50ba;p=llvm [NFC] Assert preconditions and merge all users into one codepath in Loads.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370128 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/Loads.cpp b/lib/Analysis/Loads.cpp index a40f8dd1597..e74df9c69d7 100644 --- a/lib/Analysis/Loads.cpp +++ b/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 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 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,