summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp b/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
index 2fa208fbfaaf..f9bfe8518083 100644
--- a/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
@@ -11,6 +11,7 @@
#include "llvm/CodeGen/GlobalISel/CSEInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/InitializePasses.h"
+#include "llvm/Support/Error.h"
#define DEBUG_TYPE "cseinfo"
@@ -259,8 +260,17 @@ void GISelCSEInfo::releaseMemory() {
#endif
}
+#ifndef NDEBUG
+static const char *stringify(const MachineInstr *MI, std::string &S) {
+ raw_string_ostream OS(S);
+ OS << *MI;
+ return OS.str().c_str();
+}
+#endif
+
Error GISelCSEInfo::verify() {
#ifndef NDEBUG
+ std::string S1, S2;
handleRecordedInsts();
// For each instruction in map from MI -> UMI,
// Profile(MI) and make sure UMI is found for that profile.
@@ -273,20 +283,23 @@ Error GISelCSEInfo::verify() {
if (FoundNode != It.second)
return createStringError(std::errc::not_supported,
"CSEMap mismatch, InstrMapping has MIs without "
- "corresponding Nodes in CSEMap");
+ "corresponding Nodes in CSEMap:\n%s",
+ stringify(It.second->MI, S1));
}
// For every node in the CSEMap, make sure that the InstrMapping
// points to it.
- for (auto It = CSEMap.begin(), End = CSEMap.end(); It != End; ++It) {
- const UniqueMachineInstr &UMI = *It;
+ for (const UniqueMachineInstr &UMI : CSEMap) {
if (!InstrMapping.count(UMI.MI))
return createStringError(std::errc::not_supported,
- "Node in CSE without InstrMapping", UMI.MI);
+ "Node in CSE without InstrMapping:\n%s",
+ stringify(UMI.MI, S1));
if (InstrMapping[UMI.MI] != &UMI)
return createStringError(std::make_error_code(std::errc::not_supported),
- "Mismatch in CSE mapping");
+ "Mismatch in CSE mapping:\n%s\n%s",
+ stringify(InstrMapping[UMI.MI]->MI, S1),
+ stringify(UMI.MI, S2));
}
#endif
return Error::success();