[PATCH] D130155: [DRAFT] [DeadStoreElimination] Handle null accessing
Chuanqi Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 20 02:00:05 PDT 2022
ChuanqiXu created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
After we landed https://reviews.llvm.org/D127383, the compiler may crash due to it tries to access a may-null value. This is because https://github.com/llvm/llvm-project/blob/051738b08cf5e39fd274dd379147d1c19e2b5b20/llvm/lib/Analysis/MemoryLocation.cpp#L121-L122 may return null after we land D127383 <https://reviews.llvm.org/D127383>.
https://reviews.llvm.org/D130155
Files:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1925,10 +1925,12 @@
if (auto *MemSetI = dyn_cast<MemSetInst>(UpperInst)) {
if (auto *SI = dyn_cast<StoreInst>(DefInst)) {
// MemSetInst must have a write location.
- MemoryLocation UpperLoc = *getLocForWrite(UpperInst);
+ Optional<MemoryLocation> UpperLoc = getLocForWrite(UpperInst);
+ if (!UpperLoc)
+ return false;
int64_t InstWriteOffset = 0;
int64_t DepWriteOffset = 0;
- auto OR = isOverwrite(UpperInst, DefInst, UpperLoc, *MaybeDefLoc,
+ auto OR = isOverwrite(UpperInst, DefInst, *UpperLoc, *MaybeDefLoc,
InstWriteOffset, DepWriteOffset);
Value *StoredByte = isBytewiseValue(SI->getValueOperand(), DL);
return StoredByte && StoredByte == MemSetI->getOperand(1) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130155.446082.patch
Type: text/x-patch
Size: 1102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220720/2f9a0ab5/attachment.bin>
More information about the llvm-commits
mailing list