AMDGPU: Fix crash with undef vreg input operand

llvm-svn: 305814
This commit is contained in:
Matt Arsenault 2017-06-20 18:28:02 +00:00
parent e7a35539c5
commit 7f67b35901
2 changed files with 22 additions and 1 deletions

View File

@ -470,7 +470,7 @@ static MachineOperand *getImmOrMaterializedImm(MachineRegisterInfo &MRI,
return &Op;
MachineInstr *Def = MRI.getVRegDef(Op.getReg());
if (Def->isMoveImmediate()) {
if (Def && Def->isMoveImmediate()) {
MachineOperand &ImmSrc = Def->getOperand(1);
if (ImmSrc.isImm())
return &ImmSrc;

View File

@ -68,6 +68,10 @@
ret void
}
define amdgpu_kernel void @undefined_vreg_operand() {
unreachable
}
declare i32 @llvm.amdgcn.workitem.id.x() #1
attributes #0 = { nounwind }
@ -856,3 +860,20 @@ body: |
S_ENDPGM
...
---
# There is only an undef use operand for %1, so there is no
# corresponding defining instruction
name: undefined_vreg_operand
tracksRegLiveness: true
registers:
- { id: 0, class: vgpr_32, preferred-register: '' }
- { id: 1, class: vgpr_32, preferred-register: '' }
- { id: 2, class: vgpr_32, preferred-register: '' }
body: |
bb.0:
%0 = V_MOV_B32_e32 0, implicit %exec
%2 = V_XOR_B32_e64 killed %0, undef %1, implicit %exec
S_ENDPGM
...