[PATCH] D34378: AMDGPU: Fix crash with undef vreg input operand
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 18:44:33 PDT 2017
arsenm created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, kzhuravl.
https://reviews.llvm.org/D34378
Files:
lib/Target/AMDGPU/SIFoldOperands.cpp
test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir
Index: test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir
===================================================================
--- test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir
+++ test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir
@@ -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 @@
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
+
+...
Index: lib/Target/AMDGPU/SIFoldOperands.cpp
===================================================================
--- lib/Target/AMDGPU/SIFoldOperands.cpp
+++ lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -470,7 +470,7 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34378.103137.patch
Type: text/x-patch
Size: 1435 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170620/b7e38ba3/attachment.bin>
More information about the llvm-commits
mailing list