aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2021-09-28 15:10:39 +0100
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2021-09-28 17:57:36 +0100
commit3c51b9e270bac26fdec1b06ae8dd72960a2353a3 (patch)
treee0830755ed06fd87ffdf97acbbafb95f6a66afaf /llvm/lib/Analysis/Loads.cpp
parent547e5e4ae613cf5ae3727abef84d5ac0334d9987 (diff)
downloadllvm-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.cpp4
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(