llvm / llvm/llvm-project

[PowerPC] machine verifier failure "undefined physical register" after Pre-Emit Peephole for <2 x i65> dynamic extractelement + store

Open
#197,951 0 comments 0 reactions 0 assignees View on GitHub
confirmed crash-on-valid generated by fuzzer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Live Reproducer: https://godbolt.org/z/5z1PvvK1K
Compiling the following LLVM IR with `llc -mcpu=pwr10 -verify-machineinstrs` triggers a machine verifier failure (`Bad machine code: Using an undefined physical register`).

```llvm
target triple = "powerpc64le-unknown-linux-gnu"

define void @repro(<2 x i65> %a0, i32 %ii1, <2 x i65> %a2, <2 x i65> %b2) {
entry:
%iv.vec1 = freeze <2 x i65> %b2
%ic1 = and i32 %ii1, 1
%r1 = extractelement <2 x i65> %iv.vec1, i32 %ic1
store volatile i65 %r1, ptr null, align 1
store <2 x i65> %a2, ptr null, align 1
ret void
}
```

llc command:

```sh
llc -mcpu=pwr10 -verify-machineinstrs reproducer.ll
```

Error output:

```
*** Bad machine code: Using an undefined physical register ***
- function: repro
- basic block: %bb.0 entry
- instruction: renamable $x5 = LDX $x4, killed $x5 :: (load (s64))
- operand 1: $x4
LLVM ERROR: Found 1 machine code errors.
Stack dump:
0. Program arguments: llc -mcpu=pwr10 -verify-machineinstrs reproducer.ll
1. Running pass 'Function Pass Manager' on module 'reproducer.ll'.
2. Running pass 'Verify generated machine code' on function '@repro'
```

Contributor guide

Open the contributing guide

Research direction

Start with the live Godbolt reproducer or save the LLVM IR as reproducer.ll, then run llc -mcpu=pwr10 -verify-machineinstrs reproducer.ll. Trace the Pre-Emit Peephole handling of the dynamic extractelement and store around the reported undefined $x4 in the LDX instruction. Done means the reproducer no longer triggers the machine verifier failure.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.