[llvm] r360138 - [llvm-exegesis] BenchmarkRunner::runConfiguration(): write small snippet to memory
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Tue May 7 05:28:08 PDT 2019
Author: lebedevri
Date: Tue May 7 05:28:08 2019
New Revision: 360138
URL: http://llvm.org/viewvc/llvm-project?rev=360138&view=rev
Log:
[llvm-exegesis] BenchmarkRunner::runConfiguration(): write small snippet to memory
It was previously writing this temporary snippet to file,
then reading it back, but leaving the tmp file in place.
This is both unefficient, and results in huge garbage pileup
in /tmp.
One would have thought it would have been caught during D60317..
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=360138&r1=360137&r2=360138&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkRunner.cpp Tue May 7 05:28:08 2019
@@ -117,14 +117,13 @@ BenchmarkRunner::runConfiguration(const
// that the inside instructions are repeated.
constexpr const int kMinInstructionsForSnippet = 16;
{
- auto ObjectFilePath = writeObjectFile(
- BC, GenerateInstructions(BC, kMinInstructionsForSnippet));
- if (llvm::Error E = ObjectFilePath.takeError()) {
- InstrBenchmark.Error = llvm::toString(std::move(E));
- return InstrBenchmark;
- }
+ llvm::SmallString<0> Buffer;
+ llvm::raw_svector_ostream OS(Buffer);
+ assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
+ BC.LiveIns, BC.RegisterInitialValues,
+ GenerateInstructions(BC, kMinInstructionsForSnippet), OS);
const ExecutableFunction EF(State.createTargetMachine(),
- getObjectFromFile(*ObjectFilePath));
+ getObjectFromBuffer(OS.str()));
const auto FnBytes = EF.getFunctionBytes();
InstrBenchmark.AssembledSnippet.assign(FnBytes.begin(), FnBytes.end());
}
More information about the llvm-commits
mailing list