[llvm] f8e6154 - [AMDGPU] Fix SIPostRABundler crash on null register used by dbg value

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 18 17:01:32 PST 2021


Author: Stanislav Mekhanoshin
Date: 2021-11-18T17:01:19-08:00
New Revision: f8e615462b4f1376674530cc55ab6b8993cec726

URL: https://github.com/llvm/llvm-project/commit/f8e615462b4f1376674530cc55ab6b8993cec726
DIFF: https://github.com/llvm/llvm-project/commit/f8e615462b4f1376674530cc55ab6b8993cec726.diff

LOG: [AMDGPU] Fix SIPostRABundler crash on null register used by dbg value

Recently we started generate DBG_VALUEs with $noreg operands.
This crashes SIPostRABundler, and it should not iterate these
registers anyway.

Fixes: SWDEV-311733

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

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIPostRABundler.cpp
    llvm/test/CodeGen/AMDGPU/postra-bundle-memops.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIPostRABundler.cpp b/llvm/lib/Target/AMDGPU/SIPostRABundler.cpp
index 92c54c0d673ee..13a6a718f4f2f 100644
--- a/llvm/lib/Target/AMDGPU/SIPostRABundler.cpp
+++ b/llvm/lib/Target/AMDGPU/SIPostRABundler.cpp
@@ -90,6 +90,9 @@ bool SIPostRABundler::isDependentLoad(const MachineInstr &MI) const {
 
 void SIPostRABundler::collectUsedRegUnits(const MachineInstr &MI,
                                           BitVector &UsedRegUnits) const {
+  if (MI.isDebugInstr())
+    return;
+
   for (const MachineOperand &Op : MI.operands()) {
     if (!Op.isReg() || !Op.readsReg())
       continue;

diff  --git a/llvm/test/CodeGen/AMDGPU/postra-bundle-memops.mir b/llvm/test/CodeGen/AMDGPU/postra-bundle-memops.mir
index bb96eed5d8f35..d1d090ef6b2ad 100644
--- a/llvm/test/CodeGen/AMDGPU/postra-bundle-memops.mir
+++ b/llvm/test/CodeGen/AMDGPU/postra-bundle-memops.mir
@@ -320,3 +320,21 @@ body:             |
     KILL killed $vgpr5
     KILL killed $vgpr6
 ...
+
+---
+name: post_bundle_kill_and_null_reg_dbginfo
+body:             |
+  bb.0:
+    liveins: $vgpr3_vgpr4, $vgpr5_vgpr6
+
+    ; GCN-LABEL: name: post_bundle_kill_and_null_reg_dbginfo
+    ; GCN: BUNDLE implicit-def $vgpr0, implicit-def $vgpr0_lo16, implicit-def $vgpr0_hi16, implicit-def $vgpr1, implicit-def $vgpr1_lo16, implicit-def $vgpr1_hi16, implicit $vgpr3_vgpr4, implicit $exec, implicit $vgpr5_vgpr6 {
+    ; GCN-NEXT:   $vgpr0 = GLOBAL_LOAD_DWORD $vgpr3_vgpr4, 0, 0, implicit $exec
+    ; GCN-NEXT:   DBG_VALUE $noreg, $noreg
+    ; GCN-NEXT:   $vgpr1 = GLOBAL_LOAD_DWORD $vgpr5_vgpr6, 0, 0, implicit $exec
+    ; GCN-NEXT: }
+    $vgpr0 = GLOBAL_LOAD_DWORD $vgpr3_vgpr4, 0, 0, implicit $exec
+    DBG_VALUE $noreg, $noreg
+    $vgpr1 = GLOBAL_LOAD_DWORD $vgpr5_vgpr6, 0, 0, implicit $exec
+    KILL killed $vgpr3_vgpr4, killed $vgpr5_vgpr6
+...


        


More information about the llvm-commits mailing list