8 changes: 4 additions & 4 deletions llvm/test/tools/llvm-exegesis/X86/latency/latency-WRFSBASE.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=WRFSBASE -repetition-mode=duplicate 2>&1 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=WRFSBASE -repetition-mode=loop 2>&1 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=WRFSBASE64 -repetition-mode=duplicate 2>&1 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=WRFSBASE64 -repetition-mode=loop 2>&1 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=WRFSBASE -repetition-mode=duplicate 2>&1 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=WRFSBASE -repetition-mode=loop 2>&1 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=WRFSBASE64 -repetition-mode=duplicate 2>&1 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=WRFSBASE64 -repetition-mode=loop 2>&1 | FileCheck %s

CHECK: WRFSBASE{{(64)?}}: unsupported opcode
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=ADD32rr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=ADD32rr -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=ADD32rr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=ADD32rr -repetition-mode=loop | FileCheck %s

CHECK: ---
CHECK-NEXT: mode: latency
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/latency/max-configs.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SBB8rr -max-configs-per-opcode=1 | FileCheck -check-prefixes=CHECK,CHECK1 %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SBB8rr -max-configs-per-opcode=2 | FileCheck -check-prefixes=CHECK,CHECK2 %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=SBB8rr -max-configs-per-opcode=1 | FileCheck -check-prefixes=CHECK,CHECK1 %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=SBB8rr -max-configs-per-opcode=2 | FileCheck -check-prefixes=CHECK,CHECK2 %s

CHECK: ---
CHECK-NEXT: mode: latency
Expand Down
11 changes: 11 additions & 0 deletions llvm/test/tools/llvm-exegesis/X86/latency/skip-codegen.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64r -repetition-mode=duplicate | FileCheck %s --check-prefixes=CHECK,CHECK-CODEGEN
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-snippet -opcode-name=LEA64r -repetition-mode=duplicate | FileCheck %s --check-prefixes=CHECK,CHECK-NO-CODEGEN
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-and-assemble-snippet -opcode-name=LEA64r -repetition-mode=duplicate | FileCheck %s --check-prefixes=CHECK,CHECK-CODEGEN

CHECK: ---
CHECK-NEXT: mode: latency
CHECK-NEXT: key:
CHECK-NEXT: instructions:
CHECK-NEXT: LEA64r
CHECK-CODEGEN: assembled_snippet: {{[A-Z0-9]+}}{{$}}
CHECK-NO-CODEGEN: assembled_snippet: ''{{$}}
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mi8.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD32mi8 -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD32mi8 -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD32mi8 -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD32mi8 -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mr.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD32mr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD32mr -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD32mr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD32mr -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32rm.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD32rm -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD32rm -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD32rm -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD32rm -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD_F32m.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD_F32m -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD_F32m -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD_F32m -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD_F32m -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-BEXTR32rm.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=BEXTR32rm -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=BEXTR32rm -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=BEXTR32rm -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=BEXTR32rm -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-BSF16rm.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=BSF16rm -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=BSF16rm -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=BSF16rm -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=BSF16rm -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-BTR64mr.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=BTR64mr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=BTR64mr -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=BTR64mr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=BTR64mr -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=CMOV16rm -benchmarks-file=- | FileCheck %s -check-prefixes=CHECK-YAML
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=CMOV16rm -benchmarks-file=- | FileCheck %s -check-prefixes=CHECK-YAML

# https://bugs.llvm.org/show_bug.cgi?id=41448
# Verify that we correctly serialize RegNo 0 as %noreg, not as an empty string!
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-exegesis/X86/uops/uops-FLDENVm.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=FLDENVm,FLDL2E -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=FLDENVm,FLDL2E -repetition-mode=duplicate | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-exegesis/X86/uops/uops-HLT.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops -skip-measurements --dump-object-to-disk=0 --repetition-mode=loop --loop-body-size=1000 --result-aggregation-mode=min --opcode-name=HLT --max-configs-per-opcode=8192 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code --dump-object-to-disk=0 --repetition-mode=loop --loop-body-size=1000 --result-aggregation-mode=min --opcode-name=HLT --max-configs-per-opcode=8192 | FileCheck %s

# By definition, loop repetitor can not be used for terminator instructions.
# Just check that we do not crash.
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-LEA64r.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=LEA64r -repetition-mode=duplicate -max-configs-per-opcode=2 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=LEA64r -repetition-mode=loop -max-configs-per-opcode=2 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=LEA64r -repetition-mode=duplicate -max-configs-per-opcode=2 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=LEA64r -repetition-mode=loop -max-configs-per-opcode=2 | FileCheck %s

CHECK: ---
CHECK-NEXT: mode: uops
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-exegesis/X86/uops/uops-POPCNT32rr.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=POPCNT32rr 2>&1 | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=POPCNT32rr 2>&1 | FileCheck %s

CHECK: ---
CHECK-NEXT: mode: uops
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-STD.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=STD -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=STD -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=STD -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=STD -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-VFMADDSS4rm.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=VFMADDSS4rm -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=VFMADDSS4rm -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=VFMADDSS4rm -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=VFMADDSS4rm -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-XCHG64rr.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=XCHG64rr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=XCHG64rr -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=XCHG64rr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=XCHG64rr -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-exegesis/X86/uops/uops-by-opcode-name.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD32rr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -opcode-name=ADD32rr -repetition-mode=loop | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD32rr -repetition-mode=duplicate | FileCheck %s
# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -opcode-name=ADD32rr -repetition-mode=loop | FileCheck %s

CHECK: mode: uops
CHECK-NEXT: key:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: not llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --skip-measurements -snippets-file=%s 2>&1 | FileCheck %s
# RUN: not llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=uops --benchmark-phase=assemble-measured-code -snippets-file=%s 2>&1 | FileCheck %s

# llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64-DEFREG CL 1
# llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64-DEFREG AX 1
Expand Down
7 changes: 7 additions & 0 deletions llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ class Error;

namespace exegesis {

enum class BenchmarkPhaseSelectorE {
StopBeforeAllCodegen,
StopBeforeFullCodegen,
StopBeforeMeasurements,
Measure,
};

enum class InstructionBenchmarkFilter { All, RegOnly, WithMem };

struct InstructionBenchmarkKey {
Expand Down
21 changes: 10 additions & 11 deletions llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ namespace exegesis {

BenchmarkRunner::BenchmarkRunner(const LLVMState &State,
InstructionBenchmark::ModeE Mode,
bool BenchmarkSkipMeasurements)
: State(State), Mode(Mode),
BenchmarkSkipMeasurements(BenchmarkSkipMeasurements),
BenchmarkPhaseSelectorE BenchmarkPhaseSelector)
: State(State), Mode(Mode), BenchmarkPhaseSelector(BenchmarkPhaseSelector),
Scratch(std::make_unique<ScratchSpace>()) {}

BenchmarkRunner::~BenchmarkRunner() = default;
Expand Down Expand Up @@ -171,9 +170,9 @@ BenchmarkRunner::getRunnableConfiguration(
// Assemble at least kMinInstructionsForSnippet instructions by repeating
// the snippet for debug/analysis. This is so that the user clearly
// understands that the inside instructions are repeated.
const int MinInstructionsForSnippet = 4 * Instructions.size();
const int LoopBodySizeForSnippet = 2 * Instructions.size();
{
if (BenchmarkPhaseSelector > BenchmarkPhaseSelectorE::StopBeforeAllCodegen) {
const int MinInstructionsForSnippet = 4 * Instructions.size();
const int LoopBodySizeForSnippet = 2 * Instructions.size();
auto Snippet = assembleSnippet(BC, Repetitor, MinInstructionsForSnippet,
LoopBodySizeForSnippet);
if (Error E = Snippet.takeError())
Expand All @@ -186,7 +185,7 @@ BenchmarkRunner::getRunnableConfiguration(

// Assemble NumRepetitions instructions repetitions of the snippet for
// measurements.
{
if (BenchmarkPhaseSelector > BenchmarkPhaseSelectorE::StopBeforeFullCodegen) {
auto Snippet = assembleSnippet(BC, Repetitor, InstrBenchmark.NumRepetitions,
LoopBodySize);
if (Error E = Snippet.takeError())
Expand All @@ -203,7 +202,8 @@ BenchmarkRunner::runConfiguration(RunnableConfiguration &&RC,
InstructionBenchmark &InstrBenchmark = RC.InstrBenchmark;
object::OwningBinary<object::ObjectFile> &ObjectFile = RC.ObjectFile;

if (DumpObjectToDisk) {
if (DumpObjectToDisk &&
BenchmarkPhaseSelector > BenchmarkPhaseSelectorE::StopBeforeFullCodegen) {
auto ObjectFilePath = writeObjectFile(ObjectFile.getBinary()->getData());
if (Error E = ObjectFilePath.takeError()) {
InstrBenchmark.Error = toString(std::move(E));
Expand All @@ -213,9 +213,8 @@ BenchmarkRunner::runConfiguration(RunnableConfiguration &&RC,
<< *ObjectFilePath << "\n";
}

if (BenchmarkSkipMeasurements) {
InstrBenchmark.Error =
"in --skip-measurements mode, actual measurements skipped.";
if (BenchmarkPhaseSelector < BenchmarkPhaseSelectorE::Measure) {
InstrBenchmark.Error = "actual measurements skipped.";
return std::move(InstrBenchmark);
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BenchmarkRunner {
public:
explicit BenchmarkRunner(const LLVMState &State,
InstructionBenchmark::ModeE Mode,
bool BenchmarkSkipMeasurements);
BenchmarkPhaseSelectorE BenchmarkPhaseSelector);

virtual ~BenchmarkRunner();

Expand Down Expand Up @@ -98,7 +98,7 @@ class BenchmarkRunner {
protected:
const LLVMState &State;
const InstructionBenchmark::ModeE Mode;
const bool BenchmarkSkipMeasurements;
const BenchmarkPhaseSelectorE BenchmarkPhaseSelector;

private:
virtual Expected<std::vector<BenchmarkMeasure>>
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace exegesis {

LatencyBenchmarkRunner::LatencyBenchmarkRunner(
const LLVMState &State, InstructionBenchmark::ModeE Mode,
bool BenchmarkSkipMeasurements,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector,
InstructionBenchmark::ResultAggregationModeE ResultAgg)
: BenchmarkRunner(State, Mode, BenchmarkSkipMeasurements) {
: BenchmarkRunner(State, Mode, BenchmarkPhaseSelector) {
assert((Mode == InstructionBenchmark::Latency ||
Mode == InstructionBenchmark::InverseThroughput) &&
"invalid mode");
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LatencyBenchmarkRunner : public BenchmarkRunner {
public:
LatencyBenchmarkRunner(
const LLVMState &State, InstructionBenchmark::ModeE Mode,
bool BenchmarkSkipMeasurements,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector,
InstructionBenchmark::ResultAggregationModeE ResultAggMode);
~LatencyBenchmarkRunner() override;

Expand Down
22 changes: 11 additions & 11 deletions llvm/tools/llvm-exegesis/lib/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ std::unique_ptr<SnippetGenerator> ExegesisTarget::createSnippetGenerator(
Expected<std::unique_ptr<BenchmarkRunner>>
ExegesisTarget::createBenchmarkRunner(
InstructionBenchmark::ModeE Mode, const LLVMState &State,
bool BenchmarkSkipMeasurements,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector,
InstructionBenchmark::ResultAggregationModeE ResultAggMode) const {
PfmCountersInfo PfmCounters = State.getPfmCounters();
switch (Mode) {
case InstructionBenchmark::Unknown:
return nullptr;
case InstructionBenchmark::Latency:
case InstructionBenchmark::InverseThroughput:
if (!BenchmarkSkipMeasurements && !PfmCounters.CycleCounter) {
if (BenchmarkPhaseSelector == BenchmarkPhaseSelectorE::Measure &&
!PfmCounters.CycleCounter) {
const char *ModeName = Mode == InstructionBenchmark::Latency
? "latency"
: "inverse_throughput";
Expand All @@ -94,16 +95,16 @@ ExegesisTarget::createBenchmarkRunner(
"can pass --skip-measurements to skip the actual "
"benchmarking."));
}
return createLatencyBenchmarkRunner(State, Mode, BenchmarkSkipMeasurements,
return createLatencyBenchmarkRunner(State, Mode, BenchmarkPhaseSelector,
ResultAggMode);
case InstructionBenchmark::Uops:
if (!BenchmarkSkipMeasurements && !PfmCounters.UopsCounter &&
!PfmCounters.IssueCounters)
if (BenchmarkPhaseSelector == BenchmarkPhaseSelectorE::Measure &&
!PfmCounters.UopsCounter && !PfmCounters.IssueCounters)
return make_error<Failure>(
"can't run 'uops' mode, sched model does not define uops or issue "
"counters. You can pass --skip-measurements to skip the actual "
"benchmarking.");
return createUopsBenchmarkRunner(State, BenchmarkSkipMeasurements,
return createUopsBenchmarkRunner(State, BenchmarkPhaseSelector,
ResultAggMode);
}
return nullptr;
Expand All @@ -121,17 +122,16 @@ std::unique_ptr<SnippetGenerator> ExegesisTarget::createParallelSnippetGenerator

std::unique_ptr<BenchmarkRunner> ExegesisTarget::createLatencyBenchmarkRunner(
const LLVMState &State, InstructionBenchmark::ModeE Mode,
bool BenchmarkSkipMeasurements,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector,
InstructionBenchmark::ResultAggregationModeE ResultAggMode) const {
return std::make_unique<LatencyBenchmarkRunner>(
State, Mode, BenchmarkSkipMeasurements, ResultAggMode);
State, Mode, BenchmarkPhaseSelector, ResultAggMode);
}

std::unique_ptr<BenchmarkRunner> ExegesisTarget::createUopsBenchmarkRunner(
const LLVMState &State, bool BenchmarkSkipMeasurements,
const LLVMState &State, BenchmarkPhaseSelectorE BenchmarkPhaseSelector,
InstructionBenchmark::ResultAggregationModeE /*unused*/) const {
return std::make_unique<UopsBenchmarkRunner>(State,
BenchmarkSkipMeasurements);
return std::make_unique<UopsBenchmarkRunner>(State, BenchmarkPhaseSelector);
}

static_assert(std::is_pod<PfmCountersInfo>::value,
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-exegesis/lib/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ExegesisTarget {
// Creates a benchmark runner for the given mode.
Expected<std::unique_ptr<BenchmarkRunner>> createBenchmarkRunner(
InstructionBenchmark::ModeE Mode, const LLVMState &State,
bool BenchmarkSkipMeasurements,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector,
InstructionBenchmark::ResultAggregationModeE ResultAggMode =
InstructionBenchmark::Min) const;

Expand Down Expand Up @@ -199,10 +199,10 @@ class ExegesisTarget {
const LLVMState &State, const SnippetGenerator::Options &Opts) const;
std::unique_ptr<BenchmarkRunner> virtual createLatencyBenchmarkRunner(
const LLVMState &State, InstructionBenchmark::ModeE Mode,
bool BenchmarkSkipMeasurements,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector,
InstructionBenchmark::ResultAggregationModeE ResultAggMode) const;
std::unique_ptr<BenchmarkRunner> virtual createUopsBenchmarkRunner(
const LLVMState &State, bool BenchmarkSkipMeasurements,
const LLVMState &State, BenchmarkPhaseSelectorE BenchmarkPhaseSelector,
InstructionBenchmark::ResultAggregationModeE ResultAggMode) const;

const ExegesisTarget *Next = nullptr;
Expand Down
5 changes: 3 additions & 2 deletions llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ namespace exegesis {

class UopsBenchmarkRunner : public BenchmarkRunner {
public:
UopsBenchmarkRunner(const LLVMState &State, bool BenchmarkSkipMeasurements)
UopsBenchmarkRunner(const LLVMState &State,
BenchmarkPhaseSelectorE BenchmarkPhaseSelector)
: BenchmarkRunner(State, InstructionBenchmark::Uops,
BenchmarkSkipMeasurements) {}
BenchmarkPhaseSelector) {}
~UopsBenchmarkRunner() override;

static constexpr const size_t kMinNumDifferentAddresses = 6;
Expand Down
33 changes: 26 additions & 7 deletions llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,29 @@ static cl::opt<bool> BenchmarkMeasurementsPrintProgress(
cl::desc("Produce progress indicator when performing measurements"),
cl::cat(BenchmarkOptions), cl::init(false));

static cl::opt<bool> BenchmarkSkipMeasurements(
"skip-measurements",
cl::desc("do everything except actually performing the measurements"),
cl::cat(BenchmarkOptions), cl::init(false));
static cl::opt<exegesis::BenchmarkPhaseSelectorE> BenchmarkPhaseSelector(
"benchmark-phase",
cl::desc(
"it is possible to stop the benchmarking process after some phase"),
cl::cat(BenchmarkOptions),
cl::values(
clEnumValN(exegesis::BenchmarkPhaseSelectorE::StopBeforeAllCodegen,
"prepare-snippet",
"Only generate the minimal instruction sequence"),
clEnumValN(exegesis::BenchmarkPhaseSelectorE::StopBeforeFullCodegen,
"prepare-and-assemble-snippet",
"Same as prepare-snippet, but also dumps an excerpt of the "
"sequence (hex encoded)"),
clEnumValN(exegesis::BenchmarkPhaseSelectorE::StopBeforeMeasurements,
"assemble-measured-code",
"Same as prepare-and-assemble-snippet, but also creates the "
"full sequence "
"that can be dumped to a file using --dump-object-to-disk"),
clEnumValN(
exegesis::BenchmarkPhaseSelectorE::Measure, "measure",
"Same as prepare-measured-code, but also runs the measurement "
"(default)")),
cl::init(exegesis::BenchmarkPhaseSelectorE::Measure));

static cl::opt<unsigned>
NumRepetitions("num-repetitions",
Expand Down Expand Up @@ -398,7 +417,7 @@ static void runBenchmarkConfigurations(
}

void benchmarkMain() {
if (!BenchmarkSkipMeasurements) {
if (BenchmarkPhaseSelector == BenchmarkPhaseSelectorE::Measure) {
#ifndef HAVE_LIBPFM
ExitWithError(
"benchmarking unavailable, LLVM was built without libpfm. You can pass "
Expand All @@ -417,12 +436,12 @@ void benchmarkMain() {

// Preliminary check to ensure features needed for requested
// benchmark mode are present on target CPU and/or OS.
if (!BenchmarkSkipMeasurements)
if (BenchmarkPhaseSelector == BenchmarkPhaseSelectorE::Measure)
ExitOnErr(State.getExegesisTarget().checkFeatureSupport());

const std::unique_ptr<BenchmarkRunner> Runner =
ExitOnErr(State.getExegesisTarget().createBenchmarkRunner(
BenchmarkMode, State, BenchmarkSkipMeasurements, ResultAggMode));
BenchmarkMode, State, BenchmarkPhaseSelector, ResultAggMode));
if (!Runner) {
ExitWithError("cannot create benchmark runner");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ TEST_F(ScalarEvolutionExpanderTest, ExpandNonIntegralPtrWithNullBase) {
auto *GEP = dyn_cast<GetElementPtrInst>(V);
EXPECT_TRUE(GEP);
EXPECT_TRUE(cast<Constant>(GEP->getPointerOperand())->isNullValue());
EXPECT_EQ(GEP->getNumOperands(), 2);
EXPECT_EQ(GEP->getNumOperands(), 2U);
EXPECT_TRUE(match(
GEP->getOperand(1),
m_Add(m_Shl(m_Specific(Offset), m_SpecificInt(2)), m_SpecificInt(1))));
Expand Down