llvm-reduce: Fix asserting on undef virtual registers

This was only populating the virtual register map for def operands
that appeared in the function, but that may not exist if there are
only undef uses.
This commit is contained in:
Matt Arsenault 2022-04-13 17:07:44 -04:00
parent a0f9e4ed2a
commit b4ace5da45
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,20 @@
# REQUIRES: amdgpu-registered-target
# RUN: llvm-reduce -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg --check-prefix=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t 2> %t.log
# RUN: FileCheck --match-full-lines --check-prefix=RESULT %s < %t
# CHECK-INTERESTINGNESS: S_NOP 0
# RESULT: S_ENDPGM 0, implicit undef %0:vgpr_32
# Previously the the function clone would assert due to not preserving
# virtual registers which had no defs.
---
name: undef_vreg_operand
tracksRegLiveness: true
body: |
bb.0:
S_NOP 0
S_ENDPGM 0, implicit undef %0:vgpr_32
...

View File

@ -35,11 +35,15 @@ static std::unique_ptr<MachineFunction> cloneMF(MachineFunction *SrcMF) {
for (auto &SrcMI : SrcMBB) {
for (unsigned I = 0, E = SrcMI.getNumOperands(); I < E; ++I) {
auto &DMO = SrcMI.getOperand(I);
if (!DMO.isReg() || !DMO.isDef())
if (!DMO.isReg())
continue;
Register SrcReg = DMO.getReg();
if (Register::isPhysicalRegister(SrcReg))
continue;
if (Src2DstReg.find(SrcReg) != Src2DstReg.end())
continue;
Register DstReg = DstMRI->createIncompleteVirtualRegister(
SrcMRI->getVRegName(SrcReg));
DstMRI->setRegClassOrRegBank(DstReg,