[llvm] [PHIElimination] Ensure correct copy emission for `INLINEASM_BR` indirect targets (PR #173396)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 23 11:00:39 PST 2025


================
@@ -32,7 +32,21 @@ llvm::findPHICopyInsertPoint(MachineBasicBlock* MBB, MachineBasicBlock* SuccMBB,
   // instructions that are Calls with EHPad successors or INLINEASM_BR in a
   // block.
   bool EHPadSuccessor = SuccMBB->isEHPad();
-  if (!EHPadSuccessor && !SuccMBB->isInlineAsmBrIndirectTarget())
+
+  // If the successor basic block happens to be an indirect target, and the
+  // current block, which may be the successor itself, does not contain any
+  // INLINEASM_BR, we may not need any specialized handling.
+  bool HasInlineAsmBrToSucc = false;
+  if (SuccMBB->isInlineAsmBrIndirectTarget()) {
+    for (MachineInstr &MI : *MBB) {
+      if (MI.getOpcode() == TargetOpcode::INLINEASM_BR) {
+        HasInlineAsmBrToSucc = true;
+        break;
+      }
+    }
+  }
+
+  if (!EHPadSuccessor && !HasInlineAsmBrToSucc)
----------------
antoniofrighetto wrote:

Done, thanks.

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


More information about the llvm-commits mailing list