llvm / llvm/llvm-project

[X86] `va_arg` with stack-passed pointer triggers "Using a killed virtual register" errors

Open
#198,199 1 comment 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/GPrhWj1cf

Compiling the following LLVM IR with `llc -verify-machineinstrs` aborts with `*** Bad machine code: Using a killed virtual register ***` (and `Virtual register killed in block, but needed live out`, `Virtual register defs don't dominate all uses.`).

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

define i32 @repro(i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5, ptr %va) {
entry:
%r = va_arg ptr %va, i32
ret i32 %r
}
```

llc command:

```sh
llc -verify-machineinstrs repro.ll
```

Error output:

```
# After Instruction Selection
...
*** Bad machine code: Using a killed virtual register ***
*** Bad machine code: Using a killed virtual register ***
*** Bad machine code: Virtual register killed in block, but needed live out. ***
*** Bad machine code: Virtual register defs don't dominate all uses. ***
LLVM ERROR: Found 4 machine code errors.
Stack dump:
0. Program arguments: llc -mtriple=x86_64-unknown-linux-gnu -O2 -verify-machineinstrs repro.ll
1. Running pass 'Function Pass Manager' on module 'repro.ll'.
2. Running pass 'Verify generated machine code' on function '@repro'
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.