When using a datalayout that has pointer index width != pointer size this
code triggers an assertion in Value::stripAndAccumulateConstantOffsets().
I encountered this this while compiling FreeBSD for CHERI-RISC-V.
Also update LoadsTest.cpp to use a DataLayout with index width != pointer
width to ensure this case is tested.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/
D110406
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(
LLVMContext C;
std::unique_ptr<Module> M = parseIR(C,
R"IR(
+target datalayout = "p:64:64:64:32"
%class = type <{ i32, i32 }>
define i32 @f() {