@@ -499,19 +499,20 @@ BenchmarkRunner::getRunnableConfiguration(
499
499
const SnippetRepetitor &Repetitor) const {
500
500
RunnableConfiguration RC;
501
501
502
- Benchmark &InstrBenchmark = RC.InstrBenchmark ;
503
- InstrBenchmark.Mode = Mode;
504
- InstrBenchmark.CpuName = std::string (State.getTargetMachine ().getTargetCPU ());
505
- InstrBenchmark.LLVMTriple =
502
+ Benchmark &BenchmarkResult = RC.BenchmarkResult ;
503
+ BenchmarkResult.Mode = Mode;
504
+ BenchmarkResult.CpuName =
505
+ std::string (State.getTargetMachine ().getTargetCPU ());
506
+ BenchmarkResult.LLVMTriple =
506
507
State.getTargetMachine ().getTargetTriple ().normalize ();
507
- InstrBenchmark .NumRepetitions = NumRepetitions;
508
- InstrBenchmark .Info = BC.Info ;
508
+ BenchmarkResult .NumRepetitions = NumRepetitions;
509
+ BenchmarkResult .Info = BC.Info ;
509
510
510
511
const std::vector<MCInst> &Instructions = BC.Key .Instructions ;
511
512
512
513
bool GenerateMemoryInstructions = ExecutionMode == ExecutionModeE::SubProcess;
513
514
514
- InstrBenchmark .Key = BC.Key ;
515
+ BenchmarkResult .Key = BC.Key ;
515
516
516
517
// Assemble at least kMinInstructionsForSnippet instructions by repeating
517
518
// the snippet for debug/analysis. This is so that the user clearly
@@ -526,16 +527,17 @@ BenchmarkRunner::getRunnableConfiguration(
526
527
return std::move (E);
527
528
528
529
if (auto Err = getBenchmarkFunctionBytes (*Snippet,
529
- InstrBenchmark .AssembledSnippet ))
530
+ BenchmarkResult .AssembledSnippet ))
530
531
return std::move (Err);
531
532
}
532
533
533
534
// Assemble NumRepetitions instructions repetitions of the snippet for
534
535
// measurements.
535
536
if (BenchmarkPhaseSelector >
536
537
BenchmarkPhaseSelectorE::PrepareAndAssembleSnippet) {
537
- auto Snippet = assembleSnippet (BC, Repetitor, InstrBenchmark.NumRepetitions ,
538
- LoopBodySize, GenerateMemoryInstructions);
538
+ auto Snippet =
539
+ assembleSnippet (BC, Repetitor, BenchmarkResult.NumRepetitions ,
540
+ LoopBodySize, GenerateMemoryInstructions);
539
541
if (Error E = Snippet.takeError ())
540
542
return std::move (E);
541
543
RC.ObjectFile = getObjectFromBuffer (*Snippet);
@@ -577,46 +579,46 @@ BenchmarkRunner::createFunctionExecutor(
577
579
std::pair<Error, Benchmark> BenchmarkRunner::runConfiguration (
578
580
RunnableConfiguration &&RC,
579
581
const std::optional<StringRef> &DumpFile) const {
580
- Benchmark &InstrBenchmark = RC.InstrBenchmark ;
582
+ Benchmark &BenchmarkResult = RC.BenchmarkResult ;
581
583
object::OwningBinary<object::ObjectFile> &ObjectFile = RC.ObjectFile ;
582
584
583
585
if (DumpFile && BenchmarkPhaseSelector >
584
586
BenchmarkPhaseSelectorE::PrepareAndAssembleSnippet) {
585
587
auto ObjectFilePath =
586
588
writeObjectFile (ObjectFile.getBinary ()->getData (), *DumpFile);
587
589
if (Error E = ObjectFilePath.takeError ()) {
588
- return {std::move (E), std::move (InstrBenchmark )};
590
+ return {std::move (E), std::move (BenchmarkResult )};
589
591
}
590
592
outs () << " Check generated assembly with: /usr/bin/objdump -d "
591
593
<< *ObjectFilePath << " \n " ;
592
594
}
593
595
594
596
if (BenchmarkPhaseSelector < BenchmarkPhaseSelectorE::Measure) {
595
- InstrBenchmark .Error = " actual measurements skipped." ;
596
- return {Error::success (), std::move (InstrBenchmark )};
597
+ BenchmarkResult .Error = " actual measurements skipped." ;
598
+ return {Error::success (), std::move (BenchmarkResult )};
597
599
}
598
600
599
601
Expected<std::unique_ptr<BenchmarkRunner::FunctionExecutor>> Executor =
600
- createFunctionExecutor (std::move (ObjectFile), RC.InstrBenchmark .Key );
602
+ createFunctionExecutor (std::move (ObjectFile), RC.BenchmarkResult .Key );
601
603
if (!Executor)
602
- return {Executor.takeError (), std::move (InstrBenchmark )};
604
+ return {Executor.takeError (), std::move (BenchmarkResult )};
603
605
auto NewMeasurements = runMeasurements (**Executor);
604
606
605
607
if (Error E = NewMeasurements.takeError ()) {
606
- return {std::move (E), std::move (InstrBenchmark )};
608
+ return {std::move (E), std::move (BenchmarkResult )};
607
609
}
608
- assert (InstrBenchmark .NumRepetitions > 0 && " invalid NumRepetitions" );
610
+ assert (BenchmarkResult .NumRepetitions > 0 && " invalid NumRepetitions" );
609
611
for (BenchmarkMeasure &BM : *NewMeasurements) {
610
612
// Scale the measurements by instruction.
611
- BM.PerInstructionValue /= InstrBenchmark .NumRepetitions ;
613
+ BM.PerInstructionValue /= BenchmarkResult .NumRepetitions ;
612
614
// Scale the measurements by snippet.
613
615
BM.PerSnippetValue *=
614
- static_cast <double >(InstrBenchmark .Key .Instructions .size ()) /
615
- InstrBenchmark .NumRepetitions ;
616
+ static_cast <double >(BenchmarkResult .Key .Instructions .size ()) /
617
+ BenchmarkResult .NumRepetitions ;
616
618
}
617
- InstrBenchmark .Measurements = std::move (*NewMeasurements);
619
+ BenchmarkResult .Measurements = std::move (*NewMeasurements);
618
620
619
- return {Error::success (), std::move (InstrBenchmark )};
621
+ return {Error::success (), std::move (BenchmarkResult )};
620
622
}
621
623
622
624
Expected<std::string>
0 commit comments