[llvm] [CodeGenPrepare] Handle address sinking obtained from invoke (PR #143566)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 12 19:19:57 PDT 2025


================
@@ -6099,6 +6099,13 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
       }
 
       if (!ResultIndex) {
+        auto PtrInst = dyn_cast<Instruction>(ResultPtr);
+        // Here we know that we have just a pointer without any offsets.  If
+        // this pointer comes from a different from the current basic block we
+        // need to know how to recreate it in another basic block.
+        // Currently we don't support recreation of any of instruction.
+        if (PtrInst && PtrInst->getParent() != MemoryInst->getParent())
----------------
weiguozhi wrote:

I prefer this condition. We should not modify a memory access instruction with pointer comes from argument or global value directly.

https://github.com/llvm/llvm-project/pull/143566


More information about the llvm-commits mailing list