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

Evgenii Kudriashov via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 13 10:21:55 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())
----------------
e-kud wrote:

Done. I also added tests for arguments and globals. @weiguozhi you may be interested that we don't reuse addresses in these cases: https://godbolt.org/z/q8fzce4ov

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


More information about the llvm-commits mailing list