[PATCH] D127104: MachineVerifier: Add test which the verifier incorrectly accepted before

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 05:37:59 PDT 2022


arsenm created this revision.
arsenm added reviewers: qcolombet, MatzeB.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

In the process of splitting out the liveness tracking, I accidentally
fixed these cases which should have been caught. There are still
missing errors for some cases in the entry block.


https://reviews.llvm.org/D127104

Files:
  llvm/test/MachineVerifier/register-killed-inside-loop.mir
  llvm/test/MachineVerifier/undef-virt-reg-entry-block.mir
  llvm/test/MachineVerifier/undef-virt-reg-nonentry-block.mir


Index: llvm/test/MachineVerifier/undef-virt-reg-nonentry-block.mir
===================================================================
--- /dev/null
+++ llvm/test/MachineVerifier/undef-virt-reg-nonentry-block.mir
@@ -0,0 +1,15 @@
+# REQUIRES: amdgpu-registered-target
+# RUN: not --crash llc -o - -mtriple=amdgcn-amd-amdhsa -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
+
+# CHECK: *** Bad machine code: Virtual register defs don't dominate all uses. ***
+
+---
+name:            undef_virtreg
+body:             |
+  bb.0:
+
+  bb.1:
+    %0:sreg_32 = S_AND_B32 1, %1:sreg_32, implicit-def dead $scc
+    S_ENDPGM 0, implicit %1
+
+...
Index: llvm/test/MachineVerifier/undef-virt-reg-entry-block.mir
===================================================================
--- /dev/null
+++ llvm/test/MachineVerifier/undef-virt-reg-entry-block.mir
@@ -0,0 +1,14 @@
+# XFAIL: *
+# REQUIRES: amdgpu-registered-target
+# RUN: not --crash llc -o - -mtriple=amdgcn-amd-amdhsa -run-pass=none -verify-machineinstrs %s
+
+ # FIXME: This should catch the undefined use of %0
+
+---
+name:            undef_virtreg
+body:             |
+  bb.0:
+
+    S_ENDPGM 0, implicit %0:sreg_32
+
+...
Index: llvm/test/MachineVerifier/register-killed-inside-loop.mir
===================================================================
--- /dev/null
+++ llvm/test/MachineVerifier/register-killed-inside-loop.mir
@@ -0,0 +1,31 @@
+# REQUIRES: amdgpu-registered-target
+#RUN: not --crash llc -o - -mtriple=amdgcn-amd-amdhsa -run-pass=none -verify-machineinstrs %s 2>&1 | FileCheck %s
+
+# %1 is live out of %bb.1 through the loop edge, and therefore the kill flag is invalid.
+
+# CHECK: *** Bad machine code: Virtual register killed in block, but needed live out. ***
+
+---
+name:            kill_flag_in_loop
+body:             |
+  bb.0:
+    liveins: $sgpr0, $vgpr0_vgpr1
+    successors: %bb.1(0x80000000)
+
+    %0:sreg_32 = COPY $sgpr0
+    %1:sreg_32 = S_AND_B32 1, killed %0, implicit-def dead $scc
+
+  bb.1:
+    successors: %bb.2(0x40000000), %bb.1(0x40000000)
+
+    S_CMP_EQ_I32 killed %1:sreg_32, 1, implicit-def $scc
+    S_CBRANCH_SCC0 %bb.2, implicit $scc
+    S_BRANCH %bb.1
+
+  bb.2:
+    successors: %bb.3(0x80000000)
+
+  bb.3:
+    S_ENDPGM 0
+
+...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127104.434441.patch
Type: text/x-patch
Size: 2261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220606/3fa66eb6/attachment.bin>


More information about the llvm-commits mailing list