}
Expected<BenchmarkRunner::RunnableConfiguration>
-BenchmarkRunner::getRunnableConfiguration(const BenchmarkCode &BC,
- unsigned NumRepetitions,
- unsigned LoopBodySize,
- const SnippetRepetitor &Repetitor,
- bool DumpObjectToDisk) const {
+BenchmarkRunner::getRunnableConfiguration(
+ const BenchmarkCode &BC, unsigned NumRepetitions, unsigned LoopBodySize,
+ const SnippetRepetitor &Repetitor) const {
RunnableConfiguration RC;
InstructionBenchmark &InstrBenchmark = RC.InstrBenchmark;
LoopBodySize);
if (Error E = Snippet.takeError())
return std::move(E);
- if (DumpObjectToDisk) {
- auto ObjectFilePath = writeObjectFile(*Snippet);
- if (Error E = ObjectFilePath.takeError()) {
- InstrBenchmark.Error = toString(std::move(E));
- return std::move(RC);
- }
- outs() << "Check generated assembly with: /usr/bin/objdump -d "
- << *ObjectFilePath << "\n";
- }
RC.ObjectFile = getObjectFromBuffer(*Snippet);
}
}
Expected<InstructionBenchmark>
-BenchmarkRunner::runConfiguration(RunnableConfiguration &&RC) const {
+BenchmarkRunner::runConfiguration(RunnableConfiguration &&RC,
+ bool DumpObjectToDisk) const {
InstructionBenchmark &InstrBenchmark = RC.InstrBenchmark;
object::OwningBinary<object::ObjectFile> &ObjectFile = RC.ObjectFile;
+ if (DumpObjectToDisk) {
+ auto ObjectFilePath = writeObjectFile(ObjectFile.getBinary()->getData());
+ if (Error E = ObjectFilePath.takeError()) {
+ InstrBenchmark.Error = toString(std::move(E));
+ return std::move(InstrBenchmark);
+ }
+ outs() << "Check generated assembly with: /usr/bin/objdump -d "
+ << *ObjectFilePath << "\n";
+ }
+
if (BenchmarkSkipMeasurements) {
InstrBenchmark.Error =
"in --skip-measurements mode, actual measurements skipped.";
Expected<RunnableConfiguration>
getRunnableConfiguration(const BenchmarkCode &Configuration,
unsigned NumRepetitions, unsigned LoopUnrollFactor,
- const SnippetRepetitor &Repetitor,
- bool DumpObjectToDisk) const;
+ const SnippetRepetitor &Repetitor) const;
- Expected<InstructionBenchmark>
- runConfiguration(RunnableConfiguration &&RC) const;
+ Expected<InstructionBenchmark> runConfiguration(RunnableConfiguration &&RC,
+ bool DumpObjectToDisk) const;
// Scratch space to run instructions that touch memory.
struct ScratchSpace {
for (const std::unique_ptr<const SnippetRepetitor> &Repetitor :
Repetitors) {
auto RC = ExitOnErr(Runner.getRunnableConfiguration(
- Conf, NumRepetitions, LoopBodySize, *Repetitor, DumpObjectToDisk));
+ Conf, NumRepetitions, LoopBodySize, *Repetitor));
AllResults.emplace_back(
- ExitOnErr(Runner.runConfiguration(std::move(RC))));
+ ExitOnErr(Runner.runConfiguration(std::move(RC), DumpObjectToDisk)));
}
InstructionBenchmark &Result = AllResults.front();