aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib
diff options
context:
space:
mode:
authorChristian Ulmann <christianulmann@gmail.com>2024-03-22 16:44:06 +0100
committerGitHub <noreply@github.com>2024-03-22 16:44:06 +0100
commitcb300c33059c1d14f72392ce5dffcf050ad7567d (patch)
tree773687d6d7e4b13d7cec3229849d762b6117cecc /mlir/lib
parentb0e23639c5b19030bee2b307173802914f64aad6 (diff)
downloadllvm-cb300c33059c1d14f72392ce5dffcf050ad7567d.zip
llvm-cb300c33059c1d14f72392ce5dffcf050ad7567d.tar.gz
llvm-cb300c33059c1d14f72392ce5dffcf050ad7567d.tar.bz2
[MLIR][LLVM][SROA] Fix pointer escape through stores bug (#86291)
This commit resolves a SROA bug caused by not properly checking if a llvm store operation writes the pointer to memory or not. Now, we do no longer consider stores that use a slot pointer as a value to store as fixable.
Diffstat (limited to 'mlir/lib')
-rw-r--r--mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
index 0ef1d10..f171bf7 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
@@ -251,6 +251,10 @@ bool LLVM::StoreOp::canRewire(const DestructurableMemorySlot &slot,
if (getVolatile_())
return false;
+ // Storing the pointer to memory cannot be dealt with.
+ if (getValue() == slot.ptr)
+ return false;
+
// A store always accesses the first element of the destructured slot.
auto index = IntegerAttr::get(IntegerType::get(getContext(), 32), 0);
Type subslotType = getTypeAtIndex(slot, index);