[llvm] [LiveVariables] Ignore undef PHI inputs when splitting edges (PR #227912)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 16:59:00 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-regalloc

Author: Daniel Thornburgh (mysterymath)

<details>
<summary>Changes</summary>

The addNewBlock overload without precomputed live-in sets must ignore undef PHI inputs, just as the other overload has since 2cc77b2b8a022. Otherwise, splitting an edge introduces spurious AliveBlocks entries.

Discovered downstream in llvm-mos.

Assisted by GPT-6 Astra.

---
Full diff: https://github.com/llvm/llvm-project/pull/227912.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/LiveVariables.cpp (+2-1) 


``````````diff
diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp
index 1d6168618b7513..f5ca4675ef9c28 100644
--- a/llvm/lib/CodeGen/LiveVariables.cpp
+++ b/llvm/lib/CodeGen/LiveVariables.cpp
@@ -825,7 +825,8 @@ void LiveVariables::addNewBlock(MachineBasicBlock *BB,
 
     // All registers used by PHI nodes in SuccBB must be live through BB.
     for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2)
-      if (BBI->getOperand(i+1).getMBB() == BB)
+      if (BBI->getOperand(i + 1).getMBB() == BB &&
+          BBI->getOperand(i).readsReg())
         getVarInfo(BBI->getOperand(i).getReg()).AliveBlocks.set(NumNew);
   }
 

``````````

</details>


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


More information about the llvm-commits mailing list