forked from OSchip/llvm-project
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:
parent
a0f9e4ed2a
commit
b4ace5da45
|
@ -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
|
||||
|
||||
...
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue