1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[GISel] Print better error messages for missing Combiner Observer calls

Differential revision: https://reviews.llvm.org/D105290
This commit is contained in:
Jon Roelofs 2021-07-01 08:25:30 -07:00
parent 1cbf22d059
commit a9ef1d9c4a
2 changed files with 25 additions and 6 deletions

View File

@ -260,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.
@ -274,7 +283,8 @@ 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
@ -282,11 +292,14 @@ Error GISelCSEInfo::verify() {
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();

View File

@ -153,8 +153,14 @@ bool Combiner::combineMachineInstrs(MachineFunction &MF,
MFChanged |= Changed;
} while (Changed);
assert(!CSEInfo || (!errorToBool(CSEInfo->verify()) &&
"CSEInfo is not consistent. Likely missing calls to "
"observer on mutations"));
#ifndef NDEBUG
if (CSEInfo) {
if (auto E = CSEInfo->verify()) {
errs() << E << '\n';
assert(false && "CSEInfo is not consistent. Likely missing calls to "
"observer on mutations.");
}
}
#endif
return MFChanged;
}