aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Analysis/Loads.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Analysis/Loads.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/contrib/llvm-project/llvm/lib/Analysis/Loads.cpp b/contrib/llvm-project/llvm/lib/Analysis/Loads.cpp
index 1c55f485aa76..0fbf1db0685d 100644
--- a/contrib/llvm-project/llvm/lib/Analysis/Loads.cpp
+++ b/contrib/llvm-project/llvm/lib/Analysis/Loads.cpp
@@ -147,7 +147,7 @@ static bool isDereferenceableAndAlignedPointer(
Alignment, Size, DL, CtxI, DT,
TLI, Visited, MaxDepth);
- if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
+ if (const AddrSpaceCastOperator *ASC = dyn_cast<AddrSpaceCastOperator>(V))
return isDereferenceableAndAlignedPointer(ASC->getOperand(0), Alignment,
Size, DL, CtxI, DT, TLI,
Visited, MaxDepth);
@@ -451,8 +451,8 @@ static bool areNonOverlapSameBaseLoadAndStore(const Value *LoadPtr,
const Value *StorePtr,
Type *StoreTy,
const DataLayout &DL) {
- APInt LoadOffset(DL.getTypeSizeInBits(LoadPtr->getType()), 0);
- APInt StoreOffset(DL.getTypeSizeInBits(StorePtr->getType()), 0);
+ APInt LoadOffset(DL.getIndexTypeSizeInBits(LoadPtr->getType()), 0);
+ APInt StoreOffset(DL.getIndexTypeSizeInBits(StorePtr->getType()), 0);
const Value *LoadBase = LoadPtr->stripAndAccumulateConstantOffsets(
DL, LoadOffset, /* AllowNonInbounds */ false);
const Value *StoreBase = StorePtr->stripAndAccumulateConstantOffsets(
@@ -511,8 +511,11 @@ static Value *getAvailableLoadStore(Instruction *Inst, const Value *Ptr,
if (CastInst::isBitOrNoopPointerCastable(Val->getType(), AccessTy, DL))
return Val;
- if (auto *C = dyn_cast<Constant>(Val))
- return ConstantFoldLoadThroughBitcast(C, AccessTy, DL);
+ TypeSize StoreSize = DL.getTypeStoreSize(Val->getType());
+ TypeSize LoadSize = DL.getTypeStoreSize(AccessTy);
+ if (TypeSize::isKnownLE(LoadSize, StoreSize))
+ if (auto *C = dyn_cast<Constant>(Val))
+ return ConstantFoldLoadFromConst(C, AccessTy, DL);
}
return nullptr;