Skip to content

MachineVerifier: Print name of failing subregister index #129491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 4, 2025

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Mar 3, 2025

I'm not sure of a good example to test the "does not fully support"
case.

Copy link
Contributor Author

arsenm commented Mar 3, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm marked this pull request as ready for review March 3, 2025 08:20
@llvmbot
Copy link
Member

llvmbot commented Mar 3, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

Changes

I'm not sure of a good example to test the "does not fully support"
case.


Full diff: https://github.com/llvm/llvm-project/pull/129491.diff

2 Files Affected:

  • (modified) llvm/lib/CodeGen/MachineVerifier.cpp (+4-2)
  • (added) llvm/test/MachineVerifier/AMDGPU/unsupported-subreg-index.mir (+15)
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 4ab6fc2ddc28c..87d3033038414 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -2749,13 +2749,15 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
         if (!SRC) {
           report("Invalid subregister index for virtual register", MO, MONum);
           OS << "Register class " << TRI->getRegClassName(RC)
-             << " does not support subreg index " << SubIdx << '\n';
+             << " does not support subreg index "
+             << TRI->getSubRegIndexName(SubIdx) << '\n';
           return;
         }
         if (RC != SRC) {
           report("Invalid register class for subregister index", MO, MONum);
           OS << "Register class " << TRI->getRegClassName(RC)
-             << " does not fully support subreg index " << SubIdx << '\n';
+             << " does not fully support subreg index "
+             << TRI->getSubRegIndexName(SubIdx) << '\n';
           return;
         }
       }
diff --git a/llvm/test/MachineVerifier/AMDGPU/unsupported-subreg-index.mir b/llvm/test/MachineVerifier/AMDGPU/unsupported-subreg-index.mir
new file mode 100644
index 0000000000000..80631fdcdda3e
--- /dev/null
+++ b/llvm/test/MachineVerifier/AMDGPU/unsupported-subreg-index.mir
@@ -0,0 +1,15 @@
+# RUN: not --crash llc -mtriple=amdgcn -mcpu=gfx900 -run-pass=none -o /dev/null %s 2>&1 | FileCheck %s
+
+---
+name: unsupported_subreg_index
+body:             |
+  bb.0:
+    liveins: $vgpr0_vgpr1, $sgpr0_sgpr1, $agpr0_agpr1_agpr2_agpr3
+
+    ; CHECK: *** Bad machine code: Invalid subregister index for virtual register ***
+    undef %0.sub3:vreg_96 = COPY $vgpr0
+
+    ; CHECK: *** Bad machine code: Invalid subregister index for virtual register ***
+    $vgpr0 = COPY %0.sub3
+
+...

@s-barannikov
Copy link
Contributor

I'm not sure of a good example to test the "does not fully support" case.

Maybe ARM's DPR class with ssub_0 or ssub_1 register index? Not sure it is worth testing though.

Copy link
Contributor

@s-barannikov s-barannikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arsenm arsenm force-pushed the users/arsenm/machine-verifier/print-subreg-index-name branch from 28311dc to f0b59cd Compare March 3, 2025 14:22
@arsenm arsenm force-pushed the users/arsenm/machine-verifier/print-subreg-index-name branch from f0b59cd to 9d8a1ed Compare March 3, 2025 17:15
@arsenm arsenm merged commit 4670f0d into main Mar 4, 2025
11 checks passed
@arsenm arsenm deleted the users/arsenm/machine-verifier/print-subreg-index-name branch March 4, 2025 04:25
jph-13 pushed a commit to jph-13/llvm-project that referenced this pull request Mar 21, 2025
I'm not sure of a good example to test the "does not fully support"
case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants