diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-05-18 19:09:03 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-05-18 20:50:35 +0200 |
commit | 736db2f710367946452f3f705010ada4227352b0 (patch) | |
tree | de12a1779a63960df26df811ed253bdda3e7ed1e /llvm/lib/Analysis/Loads.cpp | |
parent | 3c4ef745557506a51c5fc6db3d1cabeb8a133923 (diff) | |
download | llvm-736db2f710367946452f3f705010ada4227352b0.zip llvm-736db2f710367946452f3f705010ada4227352b0.tar.gz llvm-736db2f710367946452f3f705010ada4227352b0.tar.bz2 |
[Loads] Require Align in isSafeToLoadUnconditionally() (NFC)
Now that load/store have required alignment, accept Align here.
This also avoids uses of getPointerElementType(), which is
incompatible with opaque pointers.
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r-- | llvm/lib/Analysis/Loads.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index bf1ede5..e72ea9b 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -266,14 +266,10 @@ bool llvm::isDereferenceableAndAlignedInLoop(LoadInst *LI, Loop *L, /// /// This uses the pointee type to determine how many bytes need to be safe to /// load from the pointer. -bool llvm::isSafeToLoadUnconditionally(Value *V, MaybeAlign MA, APInt &Size, +bool llvm::isSafeToLoadUnconditionally(Value *V, Align Alignment, APInt &Size, const DataLayout &DL, Instruction *ScanFrom, const DominatorTree *DT) { - // Zero alignment means that the load has the ABI alignment for the target - const Align Alignment = - DL.getValueOrABITypeAlignment(MA, V->getType()->getPointerElementType()); - // If DT is not specified we can't make context-sensitive query const Instruction* CtxI = DT ? ScanFrom : nullptr; if (isDereferenceableAndAlignedPointer(V, Alignment, Size, DL, CtxI, DT)) @@ -308,7 +304,8 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, MaybeAlign MA, APInt &Size, return false; Value *AccessedPtr; - MaybeAlign MaybeAccessedAlign; + Type *AccessedTy; + Align AccessedAlign; if (LoadInst *LI = dyn_cast<LoadInst>(BBI)) { // Ignore volatile loads. The execution of a volatile load cannot // be used to prove an address is backed by regular memory; it can, @@ -316,20 +313,18 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, MaybeAlign MA, APInt &Size, if (LI->isVolatile()) continue; AccessedPtr = LI->getPointerOperand(); - MaybeAccessedAlign = MaybeAlign(LI->getAlignment()); + AccessedTy = LI->getType(); + AccessedAlign = LI->getAlign(); } else if (StoreInst *SI = dyn_cast<StoreInst>(BBI)) { // Ignore volatile stores (see comment for loads). if (SI->isVolatile()) continue; AccessedPtr = SI->getPointerOperand(); - MaybeAccessedAlign = MaybeAlign(SI->getAlignment()); + AccessedTy = SI->getValueOperand()->getType(); + AccessedAlign = SI->getAlign(); } else continue; - Type *AccessedTy = AccessedPtr->getType()->getPointerElementType(); - - const Align AccessedAlign = - DL.getValueOrABITypeAlignment(MaybeAccessedAlign, AccessedTy); if (AccessedAlign < Alignment) continue; @@ -345,7 +340,7 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, MaybeAlign MA, APInt &Size, return false; } -bool llvm::isSafeToLoadUnconditionally(Value *V, Type *Ty, MaybeAlign Alignment, +bool llvm::isSafeToLoadUnconditionally(Value *V, Type *Ty, Align Alignment, const DataLayout &DL, Instruction *ScanFrom, const DominatorTree *DT) { |