Skip to content

[llvm-exegesis] Error instead of aborting on verification failure #137581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions llvm/tools/llvm-exegesis/lib/Assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/Object/SymbolSize.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"

Expand Down Expand Up @@ -323,10 +324,8 @@ Error assembleToStream(const ExegesisTarget &ET,
TPC->printAndVerify("After ExegesisTarget::addTargetSpecificPasses");
// Adding the following passes:
// - postrapseudos: expands pseudo return instructions used on some targets.
// - machineverifier: checks that the MachineFunction is well formed.
// - prologepilog: saves and restore callee saved registers.
for (const char *PassName :
{"postrapseudos", "machineverifier", "prologepilog"})
for (const char *PassName : {"postrapseudos", "prologepilog"})
if (addPass(PM, PassName, *TPC))
return make_error<Failure>("Unable to add a mandatory pass");
TPC->setInitialized();
Expand All @@ -337,6 +336,10 @@ Error assembleToStream(const ExegesisTarget &ET,
return make_error<Failure>("Cannot add AsmPrinter passes");

PM.run(*Module); // Run all the passes
bool MFWellFormed =
MF.verify(nullptr, "llvm-exegesis Assembly", &outs(), false);
if (!MFWellFormed)
return make_error<Failure>("The machine function failed verification.");
return Error::success();
}

Expand Down