Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[MachineCopyPropagagation] Incorrect dead flag survives #32009

Open Quuxplusone opened 7 years ago

Quuxplusone commented 7 years ago
Bugzilla Link PR33037
Status NEW
Importance P normal
Reported by Jonas Paulsson (paulsson@linux.vnet.ibm.com)
Reported on 2017-05-15 02:06:08 -0700
Last modified on 2017-05-29 07:46:08 -0700
Version trunk
Hardware PC Linux
CC ditaliano@apple.com, junbuml@codeaurora.org, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, matze@braunis.de, paulsson@linux.vnet.ibm.com, uweigand@de.ibm.com
Fixed by commit(s)
Attachments tc_mcp_undefphysreg.ll (870 bytes, text/plain)
tc_ifconvert.ll (1247 bytes, text/plain)
Blocks PR32146
Blocked by
See also PR33047
Created attachment 18438
reduced testcase

In this MBB:

BB#0: derived from LLVM BB %BB
    %V0<def> = VGBM 0
    %V1<def,dead> = COPY %V0
    %V1<def> = COPY %V0
    %V1<def,tied1> = VLEIH %V1<kill,tied0>, 0, 1
    %V0<def> = VCEQH %V1<kill>, %V0<kill>
    %R1D<def> = LARL <cp#0>
    %V1<def> = VL %R1D<kill>, 0, %noreg; mem:LD16[ConstantPool](align=8)
    %V0<def,dead> = VPERM %V0<kill>, %V0<undef>, %V1<kill>

, 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
Quuxplusone commented 7 years ago

Attached tc_mcp_undefphysreg.ll (870 bytes, text/plain): reduced testcase

Quuxplusone commented 7 years ago

As this is a bug in MachineCopyPropagation pass, it really isn't a bug in the SystemZ backend, right?

Quuxplusone commented 7 years ago

Attached tc_ifconvert.ll (1247 bytes, text/plain): reduced testcase (fails after ifconvert)

Quuxplusone commented 7 years ago

I keep seeing this bug in testing regularly...

Quuxplusone commented 7 years ago
> 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.