[llvm-mca] Propagate fatal llvm-mca errors from library classes to driver.
Summary:
This patch introduces error handling to propagate the errors from llvm-mca library classes (or what will become library classes) up to the driver. This patch also introduces an enum to make clearer the intention of the return value for Stage::execute.
This supports PR38101.
Reviewers: andreadb, courbet, RKSimon
Reviewed By: andreadb
Subscribers: llvm-commits, tschuett, gbedwell
Differential Revision: https://reviews.llvm.org/D50561
llvm-svn: 339594
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index 5b91f4a..65c298c 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -42,6 +42,7 @@
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
@@ -502,7 +503,9 @@
}
Printer.addView(
llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, S));
- P->run();
+ auto Err = P->run();
+ if (Err)
+ report_fatal_error(toString(std::move(Err)));
Printer.printReport(TOF->os());
continue;
}
@@ -539,7 +542,9 @@
*STI, *IP, S, TimelineMaxIterations, TimelineMaxCycles));
}
- P->run();
+ auto Err = P->run();
+ if (Err)
+ report_fatal_error(toString(std::move(Err)));
Printer.printReport(TOF->os());
// Clear the InstrBuilder internal state in preparation for another round.