[llvm] dfc0ede - MachineFunction: Add verify method that accepts LiveIntervals
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 31 15:14:50 PDT 2023
Author: Matt Arsenault
Date: 2023-08-31T18:14:39-04:00
New Revision: dfc0ede1f889fbd8bf6dfca0e479ee70495786ab
URL: https://github.com/llvm/llvm-project/commit/dfc0ede1f889fbd8bf6dfca0e479ee70495786ab
DIFF: https://github.com/llvm/llvm-project/commit/dfc0ede1f889fbd8bf6dfca0e479ee70495786ab.diff
LOG: MachineFunction: Add verify method that accepts LiveIntervals
This version can be used without a PassManager
https://reviews.llvm.org/D133784
Added:
Modified:
llvm/include/llvm/CodeGen/MachineFunction.h
llvm/lib/CodeGen/MachineVerifier.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 09f9ff60f95503..6c2da626ea54b4 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -884,6 +884,12 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
bool verify(Pass *p = nullptr, const char *Banner = nullptr,
bool AbortOnError = true) const;
+ /// Run the current MachineFunction through the machine code verifier, useful
+ /// for debugger use.
+ /// \returns true if no problems were found.
+ bool verify(LiveIntervals *LiveInts, SlotIndexes *Indexes,
+ const char *Banner = nullptr, bool AbortOnError = true) const;
+
// Provide accessors for the MachineBasicBlock list...
using iterator = BasicBlockListType::iterator;
using const_iterator = BasicBlockListType::const_iterator;
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 227f1142249b71..c626b41feafac1 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -92,9 +92,15 @@ namespace {
struct MachineVerifier {
MachineVerifier(Pass *pass, const char *b) : PASS(pass), Banner(b) {}
+ MachineVerifier(const char *b, LiveVariables *LiveVars,
+ LiveIntervals *LiveInts, LiveStacks *LiveStks,
+ SlotIndexes *Indexes)
+ : Banner(b), LiveVars(LiveVars), LiveInts(LiveInts), LiveStks(LiveStks),
+ Indexes(Indexes) {}
+
unsigned verify(const MachineFunction &MF);
- Pass *const PASS;
+ Pass *const PASS = nullptr;
const char *Banner;
const MachineFunction *MF = nullptr;
const TargetMachine *TM = nullptr;
@@ -355,6 +361,16 @@ bool MachineFunction::verify(Pass *p, const char *Banner, bool AbortOnErrors)
return FoundErrors == 0;
}
+bool MachineFunction::verify(LiveIntervals *LiveInts, SlotIndexes *Indexes,
+ const char *Banner, bool AbortOnErrors) const {
+ MachineFunction &MF = const_cast<MachineFunction &>(*this);
+ unsigned FoundErrors =
+ MachineVerifier(Banner, nullptr, LiveInts, nullptr, Indexes).verify(MF);
+ if (AbortOnErrors && FoundErrors)
+ report_fatal_error("Found " + Twine(FoundErrors) + " machine code errors.");
+ return FoundErrors == 0;
+}
+
void MachineVerifier::verifySlotIndexes() const {
if (Indexes == nullptr)
return;
@@ -404,10 +420,6 @@ unsigned MachineVerifier::verify(const MachineFunction &MF) {
isFunctionTracksDebugUserValues = MF.getProperties().hasProperty(
MachineFunctionProperties::Property::TracksDebugUserValues);
- LiveVars = nullptr;
- LiveInts = nullptr;
- LiveStks = nullptr;
- Indexes = nullptr;
if (PASS) {
LiveInts = PASS->getAnalysisIfAvailable<LiveIntervals>();
// We don't want to verify LiveVariables if LiveIntervals is available.
More information about the llvm-commits
mailing list