[llvm] r334459 - [AMDGPU] prevent hitting Assertion `isReg() && "Wrong MachineOperand accessor"'

Mark Searles via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 11 17:41:26 PDT 2018


Author: msearles
Date: Mon Jun 11 17:41:26 2018
New Revision: 334459

URL: http://llvm.org/viewvc/llvm-project?rev=334459&view=rev
Log:
[AMDGPU] prevent hitting Assertion `isReg() && "Wrong MachineOperand accessor"'

The use iterator, used within findMaskOperands(), can return anything which is
not a def. isUse() requires a register, so check isReg() before calling isUse().

Differential Revision: https://reviews.llvm.org/D48047

Added:
    llvm/trunk/test/CodeGen/AMDGPU/si-lower-control-flow.mir
Modified:
    llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp?rev=334459&r1=334458&r2=334459&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp Mon Jun 11 17:41:26 2018
@@ -453,8 +453,8 @@ void SILowerControlFlow::findMaskOperand
       return;
 
   for (const auto &SrcOp : Def->explicit_operands())
-    if (SrcOp.isUse() && (!SrcOp.isReg() ||
-        TargetRegisterInfo::isVirtualRegister(SrcOp.getReg()) ||
+    if (SrcOp.isReg() && SrcOp.isUse() &&
+        (TargetRegisterInfo::isVirtualRegister(SrcOp.getReg()) ||
         SrcOp.getReg() == AMDGPU::EXEC))
       Src.push_back(SrcOp);
 }

Added: llvm/trunk/test/CodeGen/AMDGPU/si-lower-control-flow.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/si-lower-control-flow.mir?rev=334459&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/si-lower-control-flow.mir (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/si-lower-control-flow.mir Mon Jun 11 17:41:26 2018
@@ -0,0 +1,23 @@
+# RUN: llc -mtriple=amdgcn-amd-amdhsa-amdgizcl -run-pass=si-lower-control-flow -verify-machineinstrs %s -o - | FileCheck -check-prefixes=GCN %s
+
+# Check that assert is not triggered
+# GCN-LABEL: name: si-lower-control-flow{{$}}
+# GCN-CHECK: S_LOAD_DWORD_IMM
+
+--- |
+
+  define amdgpu_kernel void @si-lower-control-flow() {
+    ret void
+  }
+
+...
+---
+name: si-lower-control-flow
+body: |
+  bb.0:
+    %0:sgpr_64 = COPY $sgpr4_sgpr5
+    %1:sreg_32_xm0_xexec = S_LOAD_DWORD_IMM %0, 16, 0
+    %2:sreg_32_xm0 = S_AND_B32 %1, 255, implicit-def $scc
+    %3:sreg_32_xm0 = S_AND_B32 65535, %2, implicit-def $scc
+    S_ENDPGM
+...




More information about the llvm-commits mailing list