aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-exegesis
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2018-06-21 14:49:04 +0000
committerClement Courbet <courbet@google.com>2018-06-21 14:49:04 +0000
commit34d9682fc5578a5ca1eaaacfe22c2261778d0d9f (patch)
treeb38c6b382e39a88376b3bc97c0f743b2b495fe25 /tools/llvm-exegesis
parent016054315fd742cc1a4640ab2e96f39e6d5fb445 (diff)
[llvm-exegesis][NFC] Simplify BenchmarkRunner.
Get rid of createExecutableFunction(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335240 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-exegesis')
-rw-r--r--tools/llvm-exegesis/lib/BenchmarkRunner.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 3074cb430a4..f9ecbae060d 100644
--- a/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -91,25 +91,31 @@ BenchmarkRunner::runOne(const BenchmarkConfiguration &Configuration,
// 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::ArrayRef<llvm::MCInst> Code) const {
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