Skip to content

Commit 025b799

Browse files
author
git apple-llvm automerger
committed
Merge commit 'dfc0ede1f889' from llvm.org/main into next
2 parents 38f4c3c + dfc0ede commit 025b799

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

llvm/include/llvm/CodeGen/MachineFunction.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,12 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
884884
bool verify(Pass *p = nullptr, const char *Banner = nullptr,
885885
bool AbortOnError = true) const;
886886

887+
/// Run the current MachineFunction through the machine code verifier, useful
888+
/// for debugger use.
889+
/// \returns true if no problems were found.
890+
bool verify(LiveIntervals *LiveInts, SlotIndexes *Indexes,
891+
const char *Banner = nullptr, bool AbortOnError = true) const;
892+
887893
// Provide accessors for the MachineBasicBlock list...
888894
using iterator = BasicBlockListType::iterator;
889895
using const_iterator = BasicBlockListType::const_iterator;

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ namespace {
9292
struct MachineVerifier {
9393
MachineVerifier(Pass *pass, const char *b) : PASS(pass), Banner(b) {}
9494

95+
MachineVerifier(const char *b, LiveVariables *LiveVars,
96+
LiveIntervals *LiveInts, LiveStacks *LiveStks,
97+
SlotIndexes *Indexes)
98+
: Banner(b), LiveVars(LiveVars), LiveInts(LiveInts), LiveStks(LiveStks),
99+
Indexes(Indexes) {}
100+
95101
unsigned verify(const MachineFunction &MF);
96102

97-
Pass *const PASS;
103+
Pass *const PASS = nullptr;
98104
const char *Banner;
99105
const MachineFunction *MF = nullptr;
100106
const TargetMachine *TM = nullptr;
@@ -355,6 +361,16 @@ bool MachineFunction::verify(Pass *p, const char *Banner, bool AbortOnErrors)
355361
return FoundErrors == 0;
356362
}
357363

364+
bool MachineFunction::verify(LiveIntervals *LiveInts, SlotIndexes *Indexes,
365+
const char *Banner, bool AbortOnErrors) const {
366+
MachineFunction &MF = const_cast<MachineFunction &>(*this);
367+
unsigned FoundErrors =
368+
MachineVerifier(Banner, nullptr, LiveInts, nullptr, Indexes).verify(MF);
369+
if (AbortOnErrors && FoundErrors)
370+
report_fatal_error("Found " + Twine(FoundErrors) + " machine code errors.");
371+
return FoundErrors == 0;
372+
}
373+
358374
void MachineVerifier::verifySlotIndexes() const {
359375
if (Indexes == nullptr)
360376
return;
@@ -404,10 +420,6 @@ unsigned MachineVerifier::verify(const MachineFunction &MF) {
404420
isFunctionTracksDebugUserValues = MF.getProperties().hasProperty(
405421
MachineFunctionProperties::Property::TracksDebugUserValues);
406422

407-
LiveVars = nullptr;
408-
LiveInts = nullptr;
409-
LiveStks = nullptr;
410-
Indexes = nullptr;
411423
if (PASS) {
412424
LiveInts = PASS->getAnalysisIfAvailable<LiveIntervals>();
413425
// We don't want to verify LiveVariables if LiveIntervals is available.

0 commit comments

Comments
 (0)