[llvm] r335240 - [llvm-exegesis][NFC] Simplify BenchmarkRunner.
Clement Courbet via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 21 07:49:04 PDT 2018
Author: courbet
Date: Thu Jun 21 07:49:04 2018
New Revision: 335240
URL: http://llvm.org/viewvc/llvm-project?rev=335240&view=rev
Log:
[llvm-exegesis][NFC] Simplify BenchmarkRunner.
Get rid of createExecutableFunction().
Modified:
llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp?rev=335240&r1=335239&r2=335240&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp Thu Jun 21 07:49:04 2018
@@ -91,25 +91,31 @@ BenchmarkRunner::runOne(const BenchmarkC
// that the inside instructions are repeated.
constexpr const int kMinInstructionsForSnippet = 16;
{
- auto EF = createExecutableFunction(
+ auto ObjectFilePath = writeObjectFile(
GenerateInstructions(kMinInstructionsForSnippet));
- if (llvm::Error E = EF.takeError()) {
+ if (llvm::Error E = ObjectFilePath.takeError()) {
InstrBenchmark.Error = llvm::toString(std::move(E));
return InstrBenchmark;
}
- const auto FnBytes = EF->getFunctionBytes();
+ const ExecutableFunction EF(State.createTargetMachine(),
+ getObjectFromFile(*ObjectFilePath));
+ const auto FnBytes = EF.getFunctionBytes();
InstrBenchmark.AssembledSnippet.assign(FnBytes.begin(), FnBytes.end());
}
// Assemble NumRepetitions instructions repetitions of the snippet for
// measurements.
- auto EF = createExecutableFunction(
+ auto ObjectFilePath = writeObjectFile(
GenerateInstructions(InstrBenchmark.NumRepetitions));
- if (llvm::Error E = EF.takeError()) {
+ if (llvm::Error E = ObjectFilePath.takeError()) {
InstrBenchmark.Error = llvm::toString(std::move(E));
return InstrBenchmark;
}
- InstrBenchmark.Measurements = runMeasurements(*EF, NumRepetitions);
+ llvm::outs() << "Check generated assembly with: /usr/bin/objdump -d "
+ << *ObjectFilePath << "\n";
+ const ExecutableFunction EF(State.createTargetMachine(),
+ getObjectFromFile(*ObjectFilePath));
+ InstrBenchmark.Measurements = runMeasurements(EF, NumRepetitions);
return InstrBenchmark;
}
@@ -137,22 +143,7 @@ BenchmarkRunner::writeObjectFile(llvm::A
return std::move(E);
llvm::raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/);
assembleToStream(State.createTargetMachine(), Code, OFS);
- llvm::outs() << "Check generated assembly with: /usr/bin/objdump -d "
- << ResultPath << "\n";
return ResultPath.str();
}
-llvm::Expected<ExecutableFunction> BenchmarkRunner::createExecutableFunction(
- llvm::ArrayRef<llvm::MCInst> Code) const {
- auto ExpectedObjectPath = writeObjectFile(Code);
- if (llvm::Error E = ExpectedObjectPath.takeError()) {
- return std::move(E);
- }
-
- // FIXME: Check if TargetMachine or ExecutionEngine can be reused instead of
- // creating one everytime.
- return ExecutableFunction(State.createTargetMachine(),
- getObjectFromFile(*ExpectedObjectPath));
-}
-
} // namespace exegesis
More information about the llvm-commits
mailing list