[llvm] [LiveDebugVariables] Add basic verification (PR #68703)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 05:50:52 PDT 2023
https://github.com/jayfoad updated https://github.com/llvm/llvm-project/pull/68703
>From c759dabb71a55a956234947edbfa85d6957ddd88 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Mon, 9 Oct 2023 17:48:32 +0100
Subject: [PATCH 1/2] [LiveDebugVariables] Add basic verification
Add a basic implementation of verifyAnalysis that just checks the
IntervalMap for consistency. This was useful for diagnosing some
SlotIndexes-related problems caused by #67038.
---
llvm/lib/CodeGen/LiveDebugVariables.cpp | 16 ++++++++++++++++
llvm/lib/CodeGen/LiveDebugVariables.h | 1 +
2 files changed, 17 insertions(+)
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 9603c1f01e08569..74546230b36a239 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -491,6 +491,12 @@ class UserValue {
/// Return DebugLoc of this UserValue.
const DebugLoc &getDebugLoc() { return dl; }
+ void verify() const {
+ // Verify consistency of the intervals in locInts.
+ for (auto I = locInts.begin(), E = locInts.end(); I != E; ++I)
+ assert(LocMap::KeyTraits::nonEmpty(I.start(), I.stop()));
+ }
+
void print(raw_ostream &, const TargetRegisterInfo *);
};
@@ -654,6 +660,11 @@ class LDVImpl {
ModifiedMF = false;
}
+ void verify() const {
+ for (auto [DV, UV] : userVarMap)
+ UV->verify();
+ }
+
/// Map virtual register to an equivalence class.
void mapVirtReg(Register VirtReg, UserValue *EC);
@@ -1319,6 +1330,11 @@ void LiveDebugVariables::releaseMemory() {
static_cast<LDVImpl*>(pImpl)->clear();
}
+void LiveDebugVariables::verifyAnalysis() const {
+ if (pImpl)
+ static_cast<LDVImpl*>(pImpl)->verify();
+}
+
LiveDebugVariables::~LiveDebugVariables() {
if (pImpl)
delete static_cast<LDVImpl*>(pImpl);
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.h b/llvm/lib/CodeGen/LiveDebugVariables.h
index 9998ce9e8dad861..c99f11c8565a819 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.h
+++ b/llvm/lib/CodeGen/LiveDebugVariables.h
@@ -56,6 +56,7 @@ class LLVM_LIBRARY_VISIBILITY LiveDebugVariables : public MachineFunctionPass {
bool runOnMachineFunction(MachineFunction &) override;
void releaseMemory() override;
void getAnalysisUsage(AnalysisUsage &) const override;
+ void verifyAnalysis() const override;
MachineFunctionProperties getSetProperties() const override {
return MachineFunctionProperties().set(
>From 5ed20ab284108090084b3c2c63affb1e4e0bf74c Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Tue, 10 Oct 2023 13:50:37 +0100
Subject: [PATCH 2/2] clang-format
---
llvm/lib/CodeGen/LiveDebugVariables.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 74546230b36a239..0fa118742090e56 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -1332,7 +1332,7 @@ void LiveDebugVariables::releaseMemory() {
void LiveDebugVariables::verifyAnalysis() const {
if (pImpl)
- static_cast<LDVImpl*>(pImpl)->verify();
+ static_cast<LDVImpl *>(pImpl)->verify();
}
LiveDebugVariables::~LiveDebugVariables() {
More information about the llvm-commits
mailing list