[llvm] [RemoveDIs] Add additional debug-mode verifier checks (PR #84308)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 11 04:10:25 PDT 2024


https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/84308

>From c2babba42a8d3d177a45c6c0b834860683e957bd Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Thu, 7 Mar 2024 11:25:45 +0000
Subject: [PATCH 1/3] verifier changes base

---
 llvm/lib/IR/Verifier.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index e0de179e57146f..5dec4f14c5dbfd 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -3017,6 +3017,17 @@ void Verifier::visitBasicBlock(BasicBlock &BB) {
     Check(I.getParent() == &BB, "Instruction has bogus parent pointer!");
   }
 
+  Check(BB.IsNewDbgInfoFormat == BB.getParent()->IsNewDbgInfoFormat,
+        "BB debug format (new=" + std::to_string(BB.IsNewDbgInfoFormat) +
+            ") should match parent " + BB.getName() + " in " +
+            BB.getParent()->getName());
+  Check(BB.getParent()->IsNewDbgInfoFormat ==
+            BB.getParent()->getParent()->IsNewDbgInfoFormat,
+        "Fn debug format (new=" +
+            std::to_string(BB.getParent()->IsNewDbgInfoFormat) +
+            ") should match parent " + BB.getParent()->getName() + " in " +
+            BB.getParent()->getParent()->getName());
+
   // Confirm that no issues arise from the debug program.
   if (BB.IsNewDbgInfoFormat)
     CheckDI(!BB.getTrailingDPValues(), "Basic Block has trailing DbgRecords!",

>From c195081e5fb8747367dac38af4566e40619c139d Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Wed, 6 Mar 2024 11:15:01 +0000
Subject: [PATCH 2/3] move verifier code around, make it idiomatic

---
 llvm/lib/IR/Verifier.cpp | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 5dec4f14c5dbfd..e6e617cc40cb2d 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2674,6 +2674,11 @@ void Verifier::visitFunction(const Function &F) {
   Check(verifyAttributeCount(Attrs, FT->getNumParams()),
         "Attribute after last parameter!", &F);
 
+  Check(F.IsNewDbgInfoFormat == F.getParent()->IsNewDbgInfoFormat,
+        "Fn debug format should match parent", &F,
+        F.IsNewDbgInfoFormat, F.getParent(),
+        F.getParent()->IsNewDbgInfoFormat);
+
   bool IsIntrinsic = F.isIntrinsic();
 
   // Check function attributes.
@@ -3018,15 +3023,9 @@ void Verifier::visitBasicBlock(BasicBlock &BB) {
   }
 
   Check(BB.IsNewDbgInfoFormat == BB.getParent()->IsNewDbgInfoFormat,
-        "BB debug format (new=" + std::to_string(BB.IsNewDbgInfoFormat) +
-            ") should match parent " + BB.getName() + " in " +
-            BB.getParent()->getName());
-  Check(BB.getParent()->IsNewDbgInfoFormat ==
-            BB.getParent()->getParent()->IsNewDbgInfoFormat,
-        "Fn debug format (new=" +
-            std::to_string(BB.getParent()->IsNewDbgInfoFormat) +
-            ") should match parent " + BB.getParent()->getName() + " in " +
-            BB.getParent()->getParent()->getName());
+        "BB debug format should match parent", &BB,
+        BB.IsNewDbgInfoFormat, BB.getParent(),
+        BB.getParent()->IsNewDbgInfoFormat);
 
   // Confirm that no issues arise from the debug program.
   if (BB.IsNewDbgInfoFormat)

>From d8cb677046ca4400a16b2c924685532c2346b8ce Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Sun, 10 Mar 2024 17:26:32 +0000
Subject: [PATCH 3/3] address review feedback

---
 llvm/lib/IR/Verifier.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index e6e617cc40cb2d..8d20f344db2552 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2674,10 +2674,10 @@ void Verifier::visitFunction(const Function &F) {
   Check(verifyAttributeCount(Attrs, FT->getNumParams()),
         "Attribute after last parameter!", &F);
 
-  Check(F.IsNewDbgInfoFormat == F.getParent()->IsNewDbgInfoFormat,
-        "Fn debug format should match parent", &F,
-        F.IsNewDbgInfoFormat, F.getParent(),
-        F.getParent()->IsNewDbgInfoFormat);
+  CheckDI(F.IsNewDbgInfoFormat == F.getParent()->IsNewDbgInfoFormat,
+          "Function debug format should match parent module", &F,
+          F.IsNewDbgInfoFormat, F.getParent(),
+          F.getParent()->IsNewDbgInfoFormat);
 
   bool IsIntrinsic = F.isIntrinsic();
 
@@ -3022,10 +3022,10 @@ void Verifier::visitBasicBlock(BasicBlock &BB) {
     Check(I.getParent() == &BB, "Instruction has bogus parent pointer!");
   }
 
-  Check(BB.IsNewDbgInfoFormat == BB.getParent()->IsNewDbgInfoFormat,
-        "BB debug format should match parent", &BB,
-        BB.IsNewDbgInfoFormat, BB.getParent(),
-        BB.getParent()->IsNewDbgInfoFormat);
+  CheckDI(BB.IsNewDbgInfoFormat == BB.getParent()->IsNewDbgInfoFormat,
+          "BB debug format should match parent function", &BB,
+          BB.IsNewDbgInfoFormat, BB.getParent(),
+          BB.getParent()->IsNewDbgInfoFormat);
 
   // Confirm that no issues arise from the debug program.
   if (BB.IsNewDbgInfoFormat)



More information about the llvm-commits mailing list