From 9bac7d8165dddb2953602e1b270efc989b321c40 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Tue, 7 May 2019 12:28:08 +0000 Subject: [PATCH] [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.. llvm-svn: 360138 --- llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp index 18ce4cc..1f0ca6f 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp @@ -117,14 +117,13 @@ BenchmarkRunner::runConfiguration(const BenchmarkCode &BC, // 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()); } -- 2.7.4