aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-exegesis/lib/Assembler.cpp
diff options
context:
space:
mode:
authorAiden Grossman <aidengrossman@google.com>2025-05-20 14:48:17 -0700
committerGitHub <noreply@github.com>2025-05-20 14:48:17 -0700
commita690852b290fc9c843933f95d1c8ebb6d7b97adb (patch)
treee462d85ce0b7034b4aff66164580760ff830e654 /llvm/tools/llvm-exegesis/lib/Assembler.cpp
parent98595cfd6fe1d565821bc6507073a87bbaa7db6f (diff)
downloadllvm-a690852b290fc9c843933f95d1c8ebb6d7b97adb.zip
llvm-a690852b290fc9c843933f95d1c8ebb6d7b97adb.tar.gz
llvm-a690852b290fc9c843933f95d1c8ebb6d7b97adb.tar.bz2
[llvm-exegesis] Error instead of aborting on verification failure (#137581)
This patch makes llvm-exegesis emit an error when the machine function fails in MachineVerification rather than aborting. This allows downstream users (particularly https://github.com/google/gematria) to handle these errors rather than having the entire process crash. This essentially be NFC from the user perspective minus the addition of the new error message.
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/Assembler.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/lib/Assembler.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp
index f638478..67f3d75 100644
--- a/llvm/tools/llvm-exegesis/lib/Assembler.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Assembler.cpp
@@ -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"
@@ -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();
@@ -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();
}