aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/Loads.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-04-08 17:26:29 +0200
committerNikita Popov <npopov@redhat.com>2022-04-08 17:29:29 +0200
commit930a68765dff96927d706d258ef0c2ad9c7ec2ab (patch)
tree2c43903fa980fc2559db6535dfd40f2aa444f840 /llvm/lib/Analysis/Loads.cpp
parent29fe998eaa38d52d0f764800e17917cff1375598 (diff)
downloadllvm-930a68765dff96927d706d258ef0c2ad9c7ec2ab.zip
llvm-930a68765dff96927d706d258ef0c2ad9c7ec2ab.tar.gz
llvm-930a68765dff96927d706d258ef0c2ad9c7ec2ab.tar.bz2
[Loads] Check type size in bits during store to load forwarding
Rather than checking the rounded type store size, check the type size in bits. We don't want to forward a store of i1 to a load of i8 for example, even though they have the same type store size. The padding bits have unspecified contents. This is a partial fix for the issue reported at https://reviews.llvm.org/D115924#inline-1179482, the problem also needs to be addressed more generally in the constant folding code.
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 fafd95e..bc1d82c 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -504,8 +504,8 @@ static Value *getAvailableLoadStore(Instruction *Inst, const Value *Ptr,
if (CastInst::isBitOrNoopPointerCastable(Val->getType(), AccessTy, DL))
return Val;
- TypeSize StoreSize = DL.getTypeStoreSize(Val->getType());
- TypeSize LoadSize = DL.getTypeStoreSize(AccessTy);
+ TypeSize StoreSize = DL.getTypeSizeInBits(Val->getType());
+ TypeSize LoadSize = DL.getTypeSizeInBits(AccessTy);
if (TypeSize::isKnownLE(LoadSize, StoreSize))
if (auto *C = dyn_cast<Constant>(Val))
return ConstantFoldLoadFromConst(C, AccessTy, DL);