[llvm] [PHIElimination] Reuse existing COPY in predecessor basic block (PR #131837)

Mikael Holmén via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 30 21:44:13 PDT 2025


mikaelholmen wrote:

Hi @guy-david,

Another verifier error like this:
```
llc bbi-108462_3_aarch64.mir -o - -verify-machineinstrs -run-pass livevars,phi-node-elimination -mtriple=aarch64
```
It fails with:
```
# After Eliminate PHI nodes for register allocation
# Machine code for function main: NoPHIs, TracksLiveness

bb.0:
  successors: %bb.1(0x80000000); %bb.1(100.00%)
  liveins: $w0, $w1, $nzcv
  %0:gpr32 = COPY killed $w0
  %4:gpr32 = COPY killed $w1
  B %bb.1

bb.1:
; predecessors: %bb.0, %bb.1, %bb.2
  successors: %bb.2(0x40000000), %bb.1(0x40000000); %bb.2(50.00%), %bb.1(50.00%)
  liveins: $nzcv
  dead %2:gpr32 = COPY killed %4:gpr32
  %4:gpr32 = COPY %0:gpr32
  Bcc 1, %bb.1, implicit $nzcv

bb.2:
; predecessors: %bb.1
  successors: %bb.1(0x80000000); %bb.1(100.00%)
  liveins: $nzcv
  %4:gpr32 = IMPLICIT_DEF
  B %bb.1

# End machine code for function main.

*** Bad machine code: LiveVariables: Block should not be in AliveBlocks ***
- function:    main
- basic block: %bb.2  (0x5620b8ee9ba0)
Virtual register %3 is not needed live through the block.
LLVM ERROR: Found 1 machine code errors.
```
[bbi-108462_3_aarch64.mir.gz](https://github.com/user-attachments/files/20990979/bbi-108462_3_aarch64.mir.gz)


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


More information about the llvm-commits mailing list