diff options
author | Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> | 2021-09-28 15:10:39 +0100 |
---|---|---|
committer | Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> | 2021-09-28 17:57:36 +0100 |
commit | 3c51b9e270bac26fdec1b06ae8dd72960a2353a3 (patch) | |
tree | e0830755ed06fd87ffdf97acbbafb95f6a66afaf /llvm/lib/Analysis/Loads.cpp | |
parent | 547e5e4ae613cf5ae3727abef84d5ac0334d9987 (diff) | |
download | llvm-3c51b9e270bac26fdec1b06ae8dd72960a2353a3.zip llvm-3c51b9e270bac26fdec1b06ae8dd72960a2353a3.tar.gz llvm-3c51b9e270bac26fdec1b06ae8dd72960a2353a3.tar.bz2 |
Fix incorrect GEP bitwidth in areNonOverlapSameBaseLoadAndStore()
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
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r-- | llvm/lib/Analysis/Loads.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index 1c55f48..2e5f80d 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -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( |