[PATCH] D126661: [MachineVerifier] Fix crash on early clobbered subreg operands.
Daniil Fukalov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 30 08:41:13 PDT 2022
dfukalov created this revision.
dfukalov added reviewers: foad, MatzeB.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dfukalov requested review of this revision.
Herald added a project: LLVM.
MachineVerifier tried to checkLivenessAtDef() ignoring it is actually a subreg.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126661
Files:
llvm/lib/CodeGen/MachineVerifier.cpp
llvm/test/MachineVerifier/verifier-ec-subreg-liveness.mir
Index: llvm/test/MachineVerifier/verifier-ec-subreg-liveness.mir
===================================================================
--- /dev/null
+++ llvm/test/MachineVerifier/verifier-ec-subreg-liveness.mir
@@ -0,0 +1,39 @@
+# RUN: llc -mtriple amdgcn-amd-amdhsa -run-pass=liveintervals,simple-register-coalescing -verify-machineinstrs -o - %s | FileCheck %s
+# REQUIRES: amdgpu-registered-target
+
+# This test checks that the verifier doesn't crash on early clobbered subreg arguments.
+
+---
+name: sub0
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: vgpr_32, preferred-register: '' }
+ - { id: 1, class: vgpr_32, preferred-register: '' }
+ - { id: 2, class: vreg_64, preferred-register: '' }
+body: |
+ bb.0:
+ liveins: $vgpr0_vgpr1
+
+ ; CHECK-NOT: *** Bad machine code: Inconsistent valno->def ***
+ INLINEASM &"", 0 /* attdialect */, 1835019 /* regdef-ec:VGPR_32 */, def undef early-clobber %2.sub0, 1835018 /* regdef:VGPR_32 */, def undef %2.sub1
+ FLAT_STORE_DWORDX2 $vgpr0_vgpr1, %2, 0, 0, implicit $exec, implicit $flat_scr :: (store (s64))
+ S_ENDPGM 0
+
+...
+---
+name: sub1
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: vgpr_32, preferred-register: '' }
+ - { id: 1, class: vgpr_32, preferred-register: '' }
+ - { id: 2, class: vreg_64, preferred-register: '' }
+body: |
+ bb.0:
+ liveins: $vgpr0_vgpr1
+
+ ; CHECK-NOT: *** Bad machine code: Inconsistent valno->def ***
+ INLINEASM &"", 0 /* attdialect */, 1835018 /* regdef:VGPR_32 */, def undef %2.sub0, 1835019 /* regdef-ec:VGPR_32 */, def undef early-clobber %2.sub1
+ FLAT_STORE_DWORDX2 $vgpr0_vgpr1, %2, 0, 0, implicit $exec, implicit $flat_scr :: (store (s64))
+ S_ENDPGM 0
+
+...
Index: llvm/lib/CodeGen/MachineVerifier.cpp
===================================================================
--- llvm/lib/CodeGen/MachineVerifier.cpp
+++ llvm/lib/CodeGen/MachineVerifier.cpp
@@ -2428,7 +2428,8 @@
DefIdx = DefIdx.getRegSlot(MO->isEarlyClobber());
if (Reg.isVirtual()) {
- checkLivenessAtDef(MO, MONum, DefIdx, *LI, Reg);
+ if (SubRegIdx == 0)
+ checkLivenessAtDef(MO, MONum, DefIdx, *LI, Reg);
if (LI->hasSubRanges()) {
LaneBitmask MOMask = SubRegIdx != 0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126661.432938.patch
Type: text/x-patch
Size: 2301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220530/b03216b5/attachment.bin>
More information about the llvm-commits
mailing list