llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

"Virtual register defs don't dominate all uses" error from dead-mi-elim

Open uabjean opened this issue 7 years ago • 1 comments

Bugzilla Link 43433
Version trunk
OS Linux
Attachments minimized reproducer for ARM
CC @bjope,@darkbuck,@qcolombet

Extended Description

We start off with:

bb.0: $r0 = MOVi32imm 0 undef %0.gsub_0 = COPY $r0

bb.1: liveins: $r0 %0.gsub_0 = ADDrr %0.gsub_0, $r0, 14, $noreg, $noreg %0.gsub_1 = COPY $r0

Reproduce with:

llc -verify-machineinstrs -mtriple=arm -o - virtreg.mir -run-pass=dead-mi-elimination

and get:

bb.0: successors: %bb.1(0x80000000); %bb.1(100.00%)

$r0 = MOVi32imm 0

bb.1: ; predecessors: %bb.0 liveins: $r0 %0.gsub_1:gprpair = COPY $r0

End machine code for function f.

*** Bad machine code: Virtual register defs don't dominate all uses. ***

  • function: f
  • v. register: %0

So, gsub_0 writes are removed even though that leaves the gsub_1 write hanging (a subreg write is a read of the rest of the register).

uabjean avatar Sep 24 '19 15:09 uabjean

dead-mi-elimination assumes SSA form according to the commit mentioned below, so maybe the pass should assert on MRI->isSSA()? And then the test case here becomes invalid input to the pass.


commit 01a4b83154760ea286117ac4de9576b8a215cb8d Author: Michael Liao [email protected] Date: Wed Jan 8 10:50:23 2020 -0500

[codegen,amdgpu] Enhance MIR DIE and re-arrange it for AMDGPU.

Summary:
- `dead-mi-elimination` assumes MIR in the SSA form and cannot be
  arranged after phi elimination or DeSSA. It's enhanced to handle the
  dead register definition by skipping use check on it. Once a register
  def is `dead`, all its uses, if any, should be `undef`.
- Re-arrange the DIE in RA phase for AMDGPU by placing it directly after
  `detect-dead-lanes`.
- Many relevant tests are refined due to different register assignment.

Reviewers: rampitec, qcolombet, sunfish

Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72709

bjope avatar Jun 24 '20 09:06 bjope