summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2019-04-05 15:18:59 +0000
committerGuillaume Chatelet <gchatelet@google.com>2019-04-05 15:18:59 +0000
commit848df5b5090372402337b1f69d675ffe5cb9e466 (patch)
tree6f89488b9f974b4ed6dcd9395c423663c098510e /llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
parentfdd98782aaaba83f133af8bd1d115414c3db3425 (diff)
downloadbcm5719-llvm-848df5b5090372402337b1f69d675ffe5cb9e466.tar.gz
bcm5719-llvm-848df5b5090372402337b1f69d675ffe5cb9e466.zip
Add an option do not dump the generated object on disk
Reviewers: courbet Subscribers: llvm-commits, bdb Tags: #llvm Differential Revision: https://reviews.llvm.org/D60317 llvm-svn: 357769
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 32b68a5c23d..18ce4ccad28 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -66,8 +66,9 @@ private:
CounterName = CounterName.trim();
pfm::PerfEvent PerfEvent(CounterName);
if (!PerfEvent.valid())
- llvm::report_fatal_error(
- llvm::Twine("invalid perf event '").concat(CounterName).concat("'"));
+ llvm::report_fatal_error(llvm::Twine("invalid perf event '")
+ .concat(CounterName)
+ .concat("'"));
pfm::Counter Counter(PerfEvent);
Scratch->clear();
{
@@ -96,7 +97,8 @@ private:
InstructionBenchmark
BenchmarkRunner::runConfiguration(const BenchmarkCode &BC,
- unsigned NumRepetitions) const {
+ unsigned NumRepetitions,
+ bool DumpObjectToDisk) const {
InstructionBenchmark InstrBenchmark;
InstrBenchmark.Mode = Mode;
InstrBenchmark.CpuName = State.getTargetMachine().getTargetCPU();
@@ -129,15 +131,27 @@ BenchmarkRunner::runConfiguration(const BenchmarkCode &BC,
// Assemble NumRepetitions instructions repetitions of the snippet for
// measurements.
- auto ObjectFilePath = writeObjectFile(
- BC, GenerateInstructions(BC, InstrBenchmark.NumRepetitions));
- if (llvm::Error E = ObjectFilePath.takeError()) {
- InstrBenchmark.Error = llvm::toString(std::move(E));
- return InstrBenchmark;
+ const auto Code = GenerateInstructions(BC, InstrBenchmark.NumRepetitions);
+
+ llvm::object::OwningBinary<llvm::object::ObjectFile> ObjectFile;
+ if (DumpObjectToDisk) {
+ auto ObjectFilePath = writeObjectFile(BC, Code);
+ if (llvm::Error E = ObjectFilePath.takeError()) {
+ InstrBenchmark.Error = llvm::toString(std::move(E));
+ return InstrBenchmark;
+ }
+ llvm::outs() << "Check generated assembly with: /usr/bin/objdump -d "
+ << *ObjectFilePath << "\n";
+ ObjectFile = getObjectFromFile(*ObjectFilePath);
+ } else {
+ llvm::SmallString<0> Buffer;
+ llvm::raw_svector_ostream OS(Buffer);
+ assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
+ BC.LiveIns, BC.RegisterInitialValues, Code, OS);
+ ObjectFile = getObjectFromBuffer(OS.str());
}
- llvm::outs() << "Check generated assembly with: /usr/bin/objdump -d "
- << *ObjectFilePath << "\n";
- const FunctionExecutorImpl Executor(State, getObjectFromFile(*ObjectFilePath),
+
+ const FunctionExecutorImpl Executor(State, std::move(ObjectFile),
Scratch.get());
auto Measurements = runMeasurements(Executor);
if (llvm::Error E = Measurements.takeError()) {
OpenPOWER on IntegriCloud