diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -451,8 +451,8 @@ 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( diff --git a/llvm/unittests/Analysis/LoadsTest.cpp b/llvm/unittests/Analysis/LoadsTest.cpp --- a/llvm/unittests/Analysis/LoadsTest.cpp +++ b/llvm/unittests/Analysis/LoadsTest.cpp @@ -28,6 +28,7 @@ LLVMContext C; std::unique_ptr M = parseIR(C, R"IR( +target datalayout = "p:64:64:64:32" %class = type <{ i32, i32 }> define i32 @f() {