[MachineCopyPropagagation] Incorrect dead flag survives
| Bugzilla Link | 33037 |
| Version | trunk |
| OS | Linux |
| Blocks | llvm/llvm-project#31494 |
| Attachments | reduced testcase |
| CC | @RKSimon,@MatzeB,@JonPsson,@uweigand |
Extended Description
In this MBB:
BB#0: derived from LLVM BB %BB
%V0
, the first COPY of %V0 to %V1 has a dead flag, while the second one doesn't.
The optimization seems to think the second COPY is redundant, and calls eraseIfRedundant(). Afterwards, this results in:
%V1<def,dead> = COPY %V0
%V1<def,tied1> = VLEIH %V1<kill,tied0>, 0, 1
*** Bad machine code: Using an undefined physical register ***
- function: autogen_SD11756
- basic block: BB#0 BB (0x3c90be8)
- instruction: %V1<def,tied1> = VLEIH
- operand 1: %V1<kill,tied0>
Somehow, the dead flag should have been removed.
Run line: llc -O3 -mtriple=s390x-linux-gnu -mcpu=z13 -verify-machineinstrs -disable-cgp -pre-RA-sched=source -disable-machine-dce -join-liveintervals=false -o /dev/null ./tc_mcp_undefphysreg.ll
Found another test case for this bug, which this time showed up after if conversion. I think this is because the live in list of BB#3 is hiding the error.
Related then: I am currently cleaning up aarch64 for the following stricter machine verifier: https://reviews.llvm.org/D33650 That should at least un-hide the error.
I keep seeing this bug in testing regularly...
reduced testcase (fails after ifconvert) Found another test case for this bug, which this time showed up after if conversion. I think this is because the live in list of BB#3 is hiding the error.
Run with: llc -mtriple=s390x-linux-gnu -mcpu=z13 -O3 -verify-machineinstrs -disable-cgp -disable-machine-dce -join-liveintervals=false -disable-branch-fold tc_ifconvert.ll
BB#2: derived from LLVM BB %CF290
Live Ins: %R2D
Predecessors according to CFG: BB#1
%R0L
BB#3: derived from LLVM BB %CF260
Live Ins: %R2D %R0L %R1L
Predecessors according to CFG: BB#2
STCMux %R1L
*** IR Dump After Machine Copy Propagation Pass ***:
BB#2: derived from LLVM BB %CF290
Live Ins: %R2D
Predecessors according to CFG: BB#1
%R0L
BB#3: derived from LLVM BB %CF260
Live Ins: %R2D %R0L %R1L
Predecessors according to CFG: BB#2
STCMux %R1L
->
After If Converter
BB#2: derived from LLVM BB %CF290
Live Ins: %R2D
Predecessors according to CFG: BB#1
%R0L
*** Bad machine code: Using an undefined physical register ***
- function: autogen_SD3330
- basic block: BB#2 CF290 (0x4f6b9a8)
- instruction: STC
- operand 0: %R1L
As this is a bug in MachineCopyPropagation pass, it really isn't a bug in the SystemZ backend, right?