r164281 introduces a lot of errors to X86 atomic lowering
| Bugzilla Link | 15355 |
| Resolution | FIXED |
| Resolved on | Mar 08, 2013 22:35 |
| Version | trunk |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
| CC | @darkbuck |
Extended Description
The following tests show errors with the verifier turned on:
LLVM :: CodeGen/X86/atomic-dagsched.ll
LLVM :: CodeGen/X86/atomic-load-store-wide.ll
LLVM :: CodeGen/X86/atomic-minmax-i6432.ll
LLVM :: CodeGen/X86/atomic16.ll
LLVM :: CodeGen/X86/atomic32.ll
LLVM :: CodeGen/X86/atomic64.ll
LLVM :: CodeGen/X86/atomic6432.ll
LLVM :: CodeGen/X86/atomic8.ll
LLVM :: CodeGen/X86/atomic_op.ll
Here's an example from atomic64.ll:
After ExpandISelPseudos
Machine code for function atomic_fetch_and64: SSA
BB#0: derived from LLVM BB %0
%vreg0
BB#1: derived from LLVM BB %0
Live Ins: %RAX
Predecessors according to CFG: BB#0 BB#1
%vreg3
BB#2: derived from LLVM BB %0
Live Ins: %RAX
Predecessors according to CFG: BB#1
%vreg2
End machine code for function atomic_fetch_and64.
*** Bad machine code: Missing mayStore flag ***
- function: atomic_fetch_and64
- basic block: BB#0 (0x7fdff182ffa0)
- instruction: %RAX
= MOV64rm %vreg1, 1, %noreg, 0, %noreg; mem:Volatile LDST8[@sc64] GR64:%vreg1
*** Bad machine code: MBB has allocable live-in, but isn't entry or landing-pad. ***
- function: atomic_fetch_and64
- basic block: BB#1 (0x7fdff1830830)
*** Bad machine code: MBB has allocable live-in, but isn't entry or landing-pad. ***
- function: atomic_fetch_and64
- basic block: BB#2 (0x7fdff18308d8) LLVM ERROR: Found 3 machine code errors.
fixed in r176538 and r176580.
revised patch is submitted at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130304/167520.html for review
extra register copies are removed in the revised patch.
Cloned to rdar://13333663.
The register allocator is not required to respect live-ins/outs of allocable physical registers that are inserted prior to register allocator, hence the verifier error.
Hi Cameron
I don't understand the rule of "bad machine code". Why a live in register cannot be added in MBB if the generated code guarantee all BBs into it will prepare that live in register?
I didn't actually run any execution tests with this patch. Adding the extra copies in also regresses codegen quality slightly.
On the wide atomics there is another problem of kill flags being duplicated, e.g. from atomic-load-store-wide.ll:
After ExpandISelPseudos
Machine code for function test1: SSA
Frame Objects: fi#-3: size=4, align=8, fixed, at location [SP+12] fi#-2: size=4, align=4, fixed, at location [SP+8] fi#-1: size=4, align=16, fixed, at location [SP+4]
BB#0: derived from LLVM BB %0
%vreg0
BB#1: derived from LLVM BB %0
Live Ins: %EAX %EDX
Predecessors according to CFG: BB#0 BB#1
%vreg5
BB#2: derived from LLVM BB %0
Live Ins: %EAX %EDX
Predecessors according to CFG: BB#1
%vreg4
End machine code for function test1.
*** Bad machine code: Missing mayStore flag ***
- function: test1
- basic block: BB#0 (0x7fa319033ba0)
- instruction: %EAX
= MOV32rm %vreg2 , 1, %noreg, 0, %noreg; mem:Volatile ST8[%ptr] GR32:%vreg2
*** Bad machine code: Missing mayStore flag ***
- function: test1
- basic block: BB#0 (0x7fa319033ba0)
- instruction: %EDX
= MOV32rm %vreg2 , 1, %noreg, 4, %noreg; mem:Volatile ST8[%ptr] GR32:%vreg2
*** Bad machine code: Using a killed virtual register ***
- function: test1
- basic block: BB#0 (0x7fa319033ba0)
- instruction: %EDX
= MOV32rm %vreg2 , 1, %noreg, 4, %noreg; mem:Volatile ST8[%ptr] GR32:%vreg2 - operand 1: %vreg2
*** Bad machine code: MBB has allocable live-in, but isn't entry or landing-pad. ***
- function: test1
- basic block: BB#1 (0x7fa319034470)
*** Bad machine code: MBB has allocable live-in, but isn't entry or landing-pad. ***
- function: test1
- basic block: BB#1 (0x7fa319034470)
*** Bad machine code: MBB has allocable live-in, but isn't entry or landing-pad. ***
- function: test1
- basic block: BB#2 (0x7fa319034518)
*** Bad machine code: MBB has allocable live-in, but isn't entry or landing-pad. ***
- function: test1
- basic block: BB#2 (0x7fa319034518)
*** Bad machine code: Virtual register killed in block, but needed live out. ***
- function: test1
- basic block: BB#0 (0x7fa319033ba0) Virtual register %vreg2 is used after the block.
*** Bad machine code: Virtual register killed in block, but needed live out. ***
- function: test1
- basic block: BB#1 (0x7fa319034470) Virtual register %vreg2 is used after the block.
*** Bad machine code: Virtual register def doesn't dominate all uses. ***
- function: test1
- basic block: BB#0 (0x7fa319033ba0)
- instruction: %vreg2
= MOV32rm <fi#-1>, 1, %noreg, 0, %noreg; mem:LD4FixedStack-1 GR32:%vreg2