[llvm] 7603bfb - Revert "[llvm-exegesis] Improve error reporting in Assembler.cpp"
Miloš Stojanović via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 09:35:26 PST 2020
Author: Miloš Stojanović
Date: 2020-02-18T18:35:21+01:00
New Revision: 7603bfb4b0a6a90137d47f0182a490fe54bf7ca3
URL: https://github.com/llvm/llvm-project/commit/7603bfb4b0a6a90137d47f0182a490fe54bf7ca3
DIFF: https://github.com/llvm/llvm-project/commit/7603bfb4b0a6a90137d47f0182a490fe54bf7ca3.diff
LOG: Revert "[llvm-exegesis] Improve error reporting in Assembler.cpp"
This reverts https://reviews.llvm.org/rG63bb9fee525f
due to buildbot failures:
http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/1389
Added:
Modified:
llvm/tools/llvm-exegesis/lib/Assembler.cpp
llvm/tools/llvm-exegesis/lib/Assembler.h
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp
index 523cb913885e..bb89655435a8 100644
--- a/llvm/tools/llvm-exegesis/lib/Assembler.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Assembler.cpp
@@ -167,11 +167,11 @@ BitVector getFunctionReservedRegs(const TargetMachine &TM) {
return MF.getSubtarget().getRegisterInfo()->getReservedRegs(MF);
}
-Error assembleToStream(const ExegesisTarget &ET,
- std::unique_ptr<LLVMTargetMachine> TM,
- ArrayRef<unsigned> LiveIns,
- ArrayRef<RegisterValue> RegisterInitialValues,
- const FillFunction &Fill, raw_pwrite_stream &AsmStream) {
+void assembleToStream(const ExegesisTarget &ET,
+ std::unique_ptr<LLVMTargetMachine> TM,
+ ArrayRef<unsigned> LiveIns,
+ ArrayRef<RegisterValue> RegisterInitialValues,
+ const FillFunction &Fill, raw_pwrite_stream &AsmStream) {
auto Context = std::make_unique<LLVMContext>();
std::unique_ptr<Module> Module =
createModule(Context, TM->createDataLayout());
@@ -234,15 +234,15 @@ Error assembleToStream(const ExegesisTarget &ET,
for (const char *PassName :
{"postrapseudos", "machineverifier", "prologepilog"})
if (addPass(PM, PassName, *TPC))
- return make_error<Failure>("Unable to add a mandatory pass");
+ report_fatal_error("Unable to add a mandatory pass");
TPC->setInitialized();
// AsmPrinter is responsible for generating the assembly into AsmBuffer.
- if (TM->addAsmPrinter(PM, AsmStream, nullptr, CGFT_ObjectFile, MCContext))
- return make_error<Failure>("Cannot add AsmPrinter passes");
+ if (TM->addAsmPrinter(PM, AsmStream, nullptr, CGFT_ObjectFile,
+ MCContext))
+ report_fatal_error("Cannot add AsmPrinter passes");
PM.run(*Module); // Run all the passes
- return Error::success();
}
object::OwningBinary<object::ObjectFile>
diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.h b/llvm/tools/llvm-exegesis/lib/Assembler.h
index 2a83344b751e..5d4204e4a50c 100644
--- a/llvm/tools/llvm-exegesis/lib/Assembler.h
+++ b/llvm/tools/llvm-exegesis/lib/Assembler.h
@@ -18,7 +18,6 @@
#include <memory>
#include "BenchmarkCode.h"
-#include "Error.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -87,11 +86,11 @@ using FillFunction = std::function<void(FunctionFiller &)>;
// Instructions. Runs a set of llvm Passes to provide correct prologue and
// epilogue. Once the MachineFunction is ready, it is assembled for TM to
// AsmStream, the temporary function is eventually discarded.
-Error assembleToStream(const ExegesisTarget &ET,
- std::unique_ptr<LLVMTargetMachine> TM,
- ArrayRef<unsigned> LiveIns,
- ArrayRef<RegisterValue> RegisterInitialValues,
- const FillFunction &Fill, raw_pwrite_stream &AsmStream);
+void assembleToStream(const ExegesisTarget &ET,
+ std::unique_ptr<LLVMTargetMachine> TM,
+ ArrayRef<unsigned> LiveIns,
+ ArrayRef<RegisterValue> RegisterInitialValues,
+ const FillFunction &Fill, raw_pwrite_stream &AsmStream);
// Creates an ObjectFile in the format understood by the host.
// Note: the resulting object keeps a copy of Buffer so it can be discarded once
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 5b15bc29c60d..6981aaa46cd9 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -101,12 +101,10 @@ Expected<InstructionBenchmark> BenchmarkRunner::runConfiguration(
{
SmallString<0> Buffer;
raw_svector_ostream OS(Buffer);
- if (Error E = assembleToStream(
- State.getExegesisTarget(), State.createTargetMachine(), BC.LiveIns,
- BC.Key.RegisterInitialValues,
- Repetitor.Repeat(Instructions, kMinInstructionsForSnippet), OS)) {
- return std::move(E);
- }
+ assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
+ BC.LiveIns, BC.Key.RegisterInitialValues,
+ Repetitor.Repeat(Instructions, kMinInstructionsForSnippet),
+ OS);
const ExecutableFunction EF(State.createTargetMachine(),
getObjectFromBuffer(OS.str()));
const auto FnBytes = EF.getFunctionBytes();
@@ -131,11 +129,8 @@ Expected<InstructionBenchmark> BenchmarkRunner::runConfiguration(
} else {
SmallString<0> Buffer;
raw_svector_ostream OS(Buffer);
- if (Error E = assembleToStream(State.getExegesisTarget(),
- State.createTargetMachine(), BC.LiveIns,
- BC.Key.RegisterInitialValues, Filler, OS)) {
- return std::move(E);
- }
+ assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
+ BC.LiveIns, BC.Key.RegisterInitialValues, Filler, OS);
ObjectFile = getObjectFromBuffer(OS.str());
}
@@ -170,11 +165,8 @@ BenchmarkRunner::writeObjectFile(const BenchmarkCode &BC,
sys::fs::createTemporaryFile("snippet", "o", ResultFD, ResultPath)))
return std::move(E);
raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/);
- if (Error E = assembleToStream(
- State.getExegesisTarget(), State.createTargetMachine(), BC.LiveIns,
- BC.Key.RegisterInitialValues, FillFunction, OFS)) {
- return std::move(E);
- }
+ assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
+ BC.LiveIns, BC.Key.RegisterInitialValues, FillFunction, OFS);
return std::string(ResultPath.str());
}
More information about the llvm-commits
mailing list