[llvm-bugs] [Bug 38211] New: [RegisterScavenging] Scavenging results in "Using an undefined physical register"

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 18 05:34:06 PDT 2018


            Bug ID: 38211
           Summary: [RegisterScavenging]  Scavenging results in "Using an
                    undefined physical register"
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: paulsson at linux.vnet.ibm.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20569
  --> https://bugs.llvm.org/attachment.cgi?id=20569&action=edit
reduced testcase (llc .mir input)

This test case involves an MVC (mem-2-mem move) between two spill slots:

MVC %stack.180, 0, 16, %stack.1, 0 :: (store 16 into %stack.180, align 8),
(load 16 from %stack.1, align 8)

PrologEpilogInserter eliminates these frame indexes, and while doing so (since
the offset from SP to %stack.1 is too big) a virtual register is created to
load SP + 4096:

%12:addr64bit = LAY $r15d, 4096, $noreg

Then, $r14d is scavenged for %12. This results in:

STG killed $r14d, $r15d, 168, $noreg :: (store 8 into %stack.329)
$r14d = LAY $r15d, 4096, $noreg
MVC $r15d, 1824, 16, killed $r14d, 592 :: (store 16 into %stack.180, align 8),
(load 16 from %stack.1, align 8)
$r14d = LG $r15d, 168, $noreg :: (load 8 from %stack.329)

It seems that $14d was actually not live, so it wouldn't have needed to be
spilled and restored:

*** Bad machine code: Using an undefined physical register ***
- function:    main
- basic block: %bb.1 bb146 (0x2aa4cf914e8)
- instruction: STG killed $r14d, $r15d, 168, $noreg :: (store 8 into
- operand 0:   killed $r14d
LLVM ERROR: Found 1 machine code errors.

I am not sure exactly how this works, but it seems that
RegScavenger::scavengeRegisterBackwards() has somehow reported that $14d should
be spilled, while the MachineVerifier thinks that is not live.

bin/llc -mcpu=z13 ./tc_undefpreg_pei.mir -run-pass=prologepilog

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180718/b84b7807/attachment.html>

More information about the llvm-bugs mailing list