[llvm] [MachineVerifier] Verify consistency of MBB numbering (PR #116018)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 02:34:26 PST 2024


https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/116018

None

>From 7b43a6c00a3e2e9bb303b38ba2778291d9e186fe Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Wed, 13 Nov 2024 10:33:53 +0000
Subject: [PATCH] [MachineVerifier] Verify consistency of MBB numbering

---
 llvm/lib/CodeGen/MachineVerifier.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 3910046a1652b1..93d4054c25249a 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -717,6 +717,9 @@ MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) {
   FirstTerminator = nullptr;
   FirstNonPHI = nullptr;
 
+  if (MF->getBlockNumbered(MBB->getNumber()) != MBB)
+    report("MBB has inconsistent number", MBB);
+
   if (!MF->getProperties().hasProperty(
       MachineFunctionProperties::Property::NoPHIs) && MRI->tracksLiveness()) {
     // If this block has allocatable physical registers live-in, check that



More information about the llvm-commits mailing list