This is an archive of the discontinued LLVM Phabricator instance.

[MachineVerifier] Undef subreg operands do not require subranges
ClosedPublic

Authored by foad on Dec 8 2021, 9:43 AM.

Details

Summary

D112556 added verification that the live interval for a subreg operand
must have subranges. This patch fixes a corner case, where if all subreg
operands for a particular register are undef uses then no subranges
are required. This matches how LiveIntervalCalc would build the live
intervals in the first place, since an undef use is not considered
to read the register.

Before this patch, CodeGen/AMDGPU/no-remat-indirect-mov.mir would fail
with -early-live-intervals:

  1. After Live Interval Analysis

...

    • Bad machine code: Live interval for subreg operand has no subranges ***
  • function: index_vgpr_waterfall_loop
  • basic block: %bb.1 (0x6a9a968) [352B;496B)
  • instruction: 432B %24:vgpr_32 = V_MOV_B32_e32 undef %18.sub0:vreg_512, implicit $exec, implicit %18:vreg_512, implicit $m0
  • operand 1: undef %18.sub0:vreg_512

Diff Detail

Event Timeline

foad created this revision.Dec 8 2021, 9:43 AM
foad requested review of this revision.Dec 8 2021, 9:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2021, 9:43 AM
arsenm added inline comments.Dec 8 2021, 2:58 PM
llvm/lib/CodeGen/MachineVerifier.cpp
2232–2233

undef subreg defs do read the register (i.e. see the below readsReg check)

foad updated this revision to Diff 393134.Dec 9 2021, 6:07 AM

Only ignore undef uses, not undef defs.

foad edited the summary of this revision. (Show Details)Dec 9 2021, 6:08 AM
foad marked an inline comment as done.Dec 9 2021, 6:10 AM
foad added inline comments.
llvm/lib/CodeGen/MachineVerifier.cpp
2232–2233

They don't read it but they do write it, so we should still require subranges. Fixed now.

arsenm accepted this revision.Dec 15 2021, 4:58 PM
This revision is now accepted and ready to land.Dec 15 2021, 4:58 PM
This revision was automatically updated to reflect the committed changes.
foad marked an inline comment as done.