[llvm] e0ad2af - [exegesis] "Skip codegen" dry-run mode
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 5 06:47:46 PST 2023
Author: Roman Lebedev
Date: 2023-01-05T17:47:17+03:00
New Revision: e0ad2af6916a6c743e8ff19489818381e697d4ee
URL: https://github.com/llvm/llvm-project/commit/e0ad2af6916a6c743e8ff19489818381e697d4ee
DIFF: https://github.com/llvm/llvm-project/commit/e0ad2af6916a6c743e8ff19489818381e697d4ee.diff
LOG: [exegesis] "Skip codegen" dry-run mode
While "skip measurements mode" is super useful for test coverage,
i've come to discover it's trade-offs. It still calls back-end
to actually codegen the target assembly, and that is what is taking
80%+ of the time regardless of whether or not we skip the measurements.
On the other hand, just being able to see that exegesis can come up
with a snippet to measure something, is already very useful,
and takes maybe a second for a all-opcode sweep.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D140702
Added:
llvm/test/tools/llvm-exegesis/X86/latency/skip-codegen.s
Modified:
llvm/docs/CommandGuide/llvm-exegesis.rst
llvm/test/tools/llvm-exegesis/PowerPC/latency-by-opcode-name.s
llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s
llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-PBLENDVBrr0.s
llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-by-opcode-name.s
llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-disable-upper-sse-registers.s
llvm/test/tools/llvm-exegesis/X86/latency/dump-object-to-disk.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-CVTSD2SI64rr.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-IN16rr.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64_32r.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64r.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-SBB8rr.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-SETCCr-cond-codes-sweep.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-SQRTSSr.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-SYSENTER.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-WRFSBASE.s
llvm/test/tools/llvm-exegesis/X86/latency/latency-by-opcode-name.s
llvm/test/tools/llvm-exegesis/X86/latency/max-configs.test
llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mi8.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mr.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32rm.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD_F32m.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-BEXTR32rm.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-BSF16rm.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-BTR64mr.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-CMOV16rm-noreg-serialization.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-FLDENVm.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-HLT.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-LEA64r.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-POPCNT32rr.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-STD.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-VFMADDSS4rm.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-XCHG64rr.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-by-opcode-name.s
llvm/test/tools/llvm-exegesis/X86/uops/uops-misspelled-div.s
llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp
llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h
llvm/tools/llvm-exegesis/lib/Target.cpp
llvm/tools/llvm-exegesis/lib/Target.h
llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Removed:
################################################################################
diff --git a/llvm/docs/CommandGuide/llvm-exegesis.rst b/llvm/docs/CommandGuide/llvm-exegesis.rst
index dd4fc7864c94..b26f65e63dff 100644
--- a/llvm/docs/CommandGuide/llvm-exegesis.rst
+++ b/llvm/docs/CommandGuide/llvm-exegesis.rst
@@ -196,13 +196,16 @@ OPTIONS
In `analysis` mode, you also need to specify at least one of the
`-analysis-clusters-output-file=` and `-analysis-inconsistencies-output-file=`.
-.. option:: --skip-measurements
+.. option:: --benchmark-phase=[prepare-snippet|prepare-and-assemble-snippet|assemble-measured-code|measure]
By default, when `-mode=` is specified, the generated snippet will be executed
and measured, and that requires that we are running on the hardware for which
the snippet was generated, and that supports performance measurements.
- But sometimes, you just want to generate snippets, and this is exactly what
- this options allows one to do.
+ However, it is possible to stop at some stage before measuring. Choices are:
+ * ``prepare-snippet``: Only generate the minimal instruction sequence.
+ * ``prepare-and-assemble-snippet``: Same as ``prepare-snippet``, but also dumps an excerpt of the sequence (hex encoded).
+ * ``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``.
+ * ``measure``: Same as ``assemble-measured-code``, but also runs the measurement.
.. option:: -x86-lbr-sample-period=<nBranches/sample>
@@ -337,9 +340,8 @@ OPTIONS
.. option:: --dump-object-to-disk=true
- By default, llvm-exegesis will dump the generated code to a temporary file to
- enable code inspection. You may disable it to speed up the execution and save
- disk space.
+ If set, llvm-exegesis will dump the generated code to a temporary file to
+ enable code inspection. Disabled by default.
EXIT STATUS
-----------
diff --git a/llvm/test/tools/llvm-exegesis/PowerPC/latency-by-opcode-name.s b/llvm/test/tools/llvm-exegesis/PowerPC/latency-by-opcode-name.s
index 20e473d187eb..3d457aeb5927 100644
--- a/llvm/test/tools/llvm-exegesis/PowerPC/latency-by-opcode-name.s
+++ b/llvm/test/tools/llvm-exegesis/PowerPC/latency-by-opcode-name.s
@@ -1,4 +1,4 @@
-# RUN: llvm-exegesis -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 --skip-measurements -mode=latency -opcode-name=ADD8 | FileCheck %s
+# RUN: llvm-exegesis -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 --benchmark-phase=assemble-measured-code -mode=latency -opcode-name=ADD8 | FileCheck %s
CHECK: ---
CHECK-NEXT: mode: latency
diff --git a/llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s b/llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s
index 49b79b8d92b9..b2ad4891b5fc 100644
--- a/llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s
+++ b/llvm/test/tools/llvm-exegesis/PowerPC/unsupported-opcode.s
@@ -1,3 +1,3 @@
-# RUN: llvm-exegesis -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 --skip-measurements -mode=latency -opcode-name=SELECT_I8 2>&1 | FileCheck %s
+# RUN: llvm-exegesis -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 --benchmark-phase=assemble-measured-code -mode=latency -opcode-name=SELECT_I8 2>&1 | FileCheck %s
CHECK: Unsupported opcode: isPseudo/usesCustomInserter
diff --git a/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-PBLENDVBrr0.s b/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-PBLENDVBrr0.s
index b6bb5b9da0a5..b3fbd0be242e 100644
--- a/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-PBLENDVBrr0.s
+++ b/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-PBLENDVBrr0.s
@@ -1,4 +1,4 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=inverse_throughput --skip-measurements -x86-disable-upper-sse-registers -opcode-name=PBLENDVBrr0 -repetition-mode=loop | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=inverse_throughput --benchmark-phase=assemble-measured-code -x86-disable-upper-sse-registers -opcode-name=PBLENDVBrr0 -repetition-mode=loop | FileCheck %s
CHECK: ---
CHECK-NEXT: mode: inverse_throughput
diff --git a/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-by-opcode-name.s b/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-by-opcode-name.s
index 49c020b3de2a..0f3817e1a5a6 100644
--- a/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-by-opcode-name.s
+++ b/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-by-opcode-name.s
@@ -1,5 +1,5 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=inverse_throughput --skip-measurements -opcode-name=ADD32rr -repetition-mode=duplicate | FileCheck %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=inverse_throughput --skip-measurements -opcode-name=ADD32rr -repetition-mode=loop | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=inverse_throughput --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=inverse_throughput --benchmark-phase=assemble-measured-code -opcode-name=ADD32rr -repetition-mode=loop | FileCheck %s
CHECK: ---
CHECK-NEXT: mode: inverse_throughput
diff --git a/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-disable-upper-sse-registers.s b/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-disable-upper-sse-registers.s
index 65921fded886..fe07f40fac8d 100644
--- a/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-disable-upper-sse-registers.s
+++ b/llvm/test/tools/llvm-exegesis/X86/inverse_throughput/inverse_throughput-disable-upper-sse-registers.s
@@ -1,4 +1,4 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=inverse_throughput --skip-measurements -x86-disable-upper-sse-registers -opcode-name=ADDPSrr -repetition-mode=loop | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=inverse_throughput --benchmark-phase=assemble-measured-code -x86-disable-upper-sse-registers -opcode-name=ADDPSrr -repetition-mode=loop | FileCheck %s
CHECK: ---
CHECK-NEXT: mode: inverse_throughput
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/dump-object-to-disk.s b/llvm/test/tools/llvm-exegesis/X86/latency/dump-object-to-disk.s
index 607c33957132..5f8bab4ac622 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/dump-object-to-disk.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/dump-object-to-disk.s
@@ -1,9 +1,23 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=ADDPSrr -repetition-mode=duplicate -dump-object-to-disk=1 2>&1 | FileCheck %s --check-prefix=CHECK-ON
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=ADDPSrr -repetition-mode=loop -dump-object-to-disk=1 2>&1 | FileCheck %s --check-prefix=CHECK-ON
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=ADDPSrr -repetition-mode=duplicate -dump-object-to-disk=0 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=ADDPSrr -repetition-mode=loop -dump-object-to-disk=0 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=ADDPSrr -repetition-mode=duplicate 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=ADDPSrr -repetition-mode=loop 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=ADDPSrr -repetition-mode=duplicate -dump-object-to-disk=1 2>&1 | FileCheck %s --check-prefix=CHECK-ON
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=ADDPSrr -repetition-mode=loop -dump-object-to-disk=1 2>&1 | FileCheck %s --check-prefix=CHECK-ON
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=ADDPSrr -repetition-mode=duplicate -dump-object-to-disk=0 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=ADDPSrr -repetition-mode=loop -dump-object-to-disk=0 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=ADDPSrr -repetition-mode=duplicate 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=ADDPSrr -repetition-mode=loop 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-and-assemble-snippet -opcode-name=ADDPSrr -repetition-mode=duplicate -dump-object-to-disk=1 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-and-assemble-snippet -opcode-name=ADDPSrr -repetition-mode=loop -dump-object-to-disk=1 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-and-assemble-snippet -opcode-name=ADDPSrr -repetition-mode=duplicate -dump-object-to-disk=0 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-and-assemble-snippet -opcode-name=ADDPSrr -repetition-mode=loop -dump-object-to-disk=0 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-and-assemble-snippet -opcode-name=ADDPSrr -repetition-mode=duplicate 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-and-assemble-snippet -opcode-name=ADDPSrr -repetition-mode=loop 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-snippet -opcode-name=ADDPSrr -repetition-mode=duplicate -dump-object-to-disk=1 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-snippet -opcode-name=ADDPSrr -repetition-mode=loop -dump-object-to-disk=1 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-snippet -opcode-name=ADDPSrr -repetition-mode=duplicate -dump-object-to-disk=0 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-snippet -opcode-name=ADDPSrr -repetition-mode=loop -dump-object-to-disk=0 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-snippet -opcode-name=ADDPSrr -repetition-mode=duplicate 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=prepare-snippet -opcode-name=ADDPSrr -repetition-mode=loop 2>&1 | FileCheck %s --check-prefix=CHECK-OFF
CHECK-ON: Check generated assembly with
CHECK-OFF-NOT: Check generated assembly with
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s
index 2598c04cb09d..9cdd9bf029d0 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-CMOV32rr.s
@@ -1,6 +1,6 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=CMOV32rr -repetition-mode=duplicate | FileCheck %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=CMOV32rr -repetition-mode=loop | FileCheck %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=CMOV32rr -repetition-mode=min | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=CMOV32rr -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=CMOV32rr -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=CMOV32rr -repetition-mode=min | FileCheck %s
CHECK: ---
CHECK-NEXT: mode: latency
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-CVTSD2SI64rr.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-CVTSD2SI64rr.s
index ecc0853b2be9..e2fe54e080ac 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-CVTSD2SI64rr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-CVTSD2SI64rr.s
@@ -1,4 +1,4 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=CVTSD2SI64rr -repetition-mode=loop --max-configs-per-opcode=8192 | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=CVTSD2SI64rr -repetition-mode=loop --max-configs-per-opcode=8192 | FileCheck %s
# We used to fail to setup the snippet, and that disabled liveness tracking
# which we'd then tried to access during this run-line.
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-IN16rr.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-IN16rr.s
index 4a1e66fae856..8b4f42dd3201 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-IN16rr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-IN16rr.s
@@ -1,4 +1,4 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=IN16rr -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=IN16rr -repetition-mode=duplicate | FileCheck %s
# FIXME: Sometimes fails with: 'unimplemented operand type'
# ALLOW_RETRIES: 2
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64_32r.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64_32r.s
index 37daea530ab0..499dffe9b678 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64_32r.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64_32r.s
@@ -1,16 +1,16 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=LEA64_32r -repetition-mode=duplicate -max-configs-per-opcode=2 | FileCheck %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=LEA64_32r -repetition-mode=duplicate -max-configs-per-opcode=2 | FileCheck --check-prefix CHECK-COUNTS %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64_32r -repetition-mode=duplicate -max-configs-per-opcode=2 | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64_32r -repetition-mode=duplicate -max-configs-per-opcode=2 | FileCheck --check-prefix CHECK-COUNTS %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=LEA64_32r -repetition-mode=loop -max-configs-per-opcode=2 | FileCheck %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=LEA64_32r -repetition-mode=loop -max-configs-per-opcode=2 | FileCheck --check-prefix CHECK-COUNTS %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64_32r -repetition-mode=loop -max-configs-per-opcode=2 | FileCheck %s
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64_32r -repetition-mode=loop -max-configs-per-opcode=2 | FileCheck --check-prefix CHECK-COUNTS %s
## Intentionally run llvm-exegesis twice per output!
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=LEA64_32r -repetition-mode=duplicate -max-configs-per-opcode=2 --benchmarks-file=%t.duplicate.yaml
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=LEA64_32r -repetition-mode=duplicate -max-configs-per-opcode=2 --benchmarks-file=%t.duplicate.yaml
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64_32r -repetition-mode=duplicate -max-configs-per-opcode=2 --benchmarks-file=%t.duplicate.yaml
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64_32r -repetition-mode=duplicate -max-configs-per-opcode=2 --benchmarks-file=%t.duplicate.yaml
# RUN: FileCheck --input-file %t.duplicate.yaml %s
# RUN: FileCheck --input-file %t.duplicate.yaml --check-prefix CHECK-COUNTS %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=LEA64_32r -repetition-mode=loop -max-configs-per-opcode=2 --benchmarks-file=%t.loop.yaml
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=LEA64_32r -repetition-mode=loop -max-configs-per-opcode=2 --benchmarks-file=%t.loop.yaml
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64_32r -repetition-mode=loop -max-configs-per-opcode=2 --benchmarks-file=%t.loop.yaml
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64_32r -repetition-mode=loop -max-configs-per-opcode=2 --benchmarks-file=%t.loop.yaml
# RUN: FileCheck --input-file %t.loop.yaml %s
# RUN: FileCheck --input-file %t.loop.yaml --check-prefix CHECK-COUNTS %s
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64r.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64r.s
index 111511882800..7d72fd430481 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64r.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-LEA64r.s
@@ -1,5 +1,5 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --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=latency --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=latency --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=latency --benchmark-phase=assemble-measured-code -opcode-name=LEA64r -repetition-mode=loop -max-configs-per-opcode=2 | FileCheck %s
CHECK: ---
CHECK-NEXT: mode: latency
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SBB8rr.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SBB8rr.s
index 8be38e596e8a..c20e687cf20d 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SBB8rr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SBB8rr.s
@@ -1,5 +1,5 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SBB8rr -repetition-mode=duplicate | FileCheck %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SBB8rr -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=SBB8rr -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=SBB8rr -repetition-mode=loop | FileCheck %s
CHECK: ---
CHECK-NEXT: mode: latency
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SETCCr-cond-codes-sweep.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SETCCr-cond-codes-sweep.s
index d60df84bc0ea..559b3ef221ae 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SETCCr-cond-codes-sweep.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SETCCr-cond-codes-sweep.s
@@ -1,5 +1,5 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SETCCr --max-configs-per-opcode=1 | FileCheck %s --check-prefix=CHECK
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SETCCr --max-configs-per-opcode=256 | FileCheck %s --check-prefix=SWEEP
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=SETCCr --max-configs-per-opcode=1 | FileCheck %s --check-prefix=CHECK
+# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --benchmark-phase=assemble-measured-code -opcode-name=SETCCr --max-configs-per-opcode=256 | FileCheck %s --check-prefix=SWEEP
CHECK: ---
CHECK-NEXT: mode: latency
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SQRTSSr.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SQRTSSr.s
index 5c607c15cb25..7e67a4343f4e 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SQRTSSr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SQRTSSr.s
@@ -1,4 +1,4 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SQRTSSr -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=SQRTSSr -repetition-mode=loop | FileCheck %s
# Check that the setup code for MXCSR does not crash the snippet.
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SYSENTER.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SYSENTER.s
index b82b0bf10c45..c43afff5f5d9 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-SYSENTER.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-SYSENTER.s
@@ -1,4 +1,4 @@
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SYSENTER -repetition-mode=duplicate 2>&1 | FileCheck %s
-# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mode=latency --skip-measurements -opcode-name=SYSENTER -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=SYSENTER -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=SYSENTER -repetition-mode=loop 2>&1 | FileCheck %s
CHECK: SYSENTER: unsupported opcode
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-WRFSBASE.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-WRFSBASE.s
index 7420067b9bcd..5a2e6cf3f041 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-WRFSBASE.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-WRFSBASE.s
@@ -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
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/latency-by-opcode-name.s b/llvm/test/tools/llvm-exegesis/X86/latency/latency-by-opcode-name.s
index 3121f64b5ba7..4fee6fe92709 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/latency-by-opcode-name.s
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/latency-by-opcode-name.s
@@ -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
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/max-configs.test b/llvm/test/tools/llvm-exegesis/X86/latency/max-configs.test
index 98e95f0838d2..382e742144ac 100644
--- a/llvm/test/tools/llvm-exegesis/X86/latency/max-configs.test
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/max-configs.test
@@ -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
diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/skip-codegen.s b/llvm/test/tools/llvm-exegesis/X86/latency/skip-codegen.s
new file mode 100644
index 000000000000..9375b559136b
--- /dev/null
+++ b/llvm/test/tools/llvm-exegesis/X86/latency/skip-codegen.s
@@ -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: ''{{$}}
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mi8.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mi8.s
index c32777cf5acc..f8af702c6ea1 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mi8.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mi8.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mr.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mr.s
index e0d9c239c066..3298d3f61339 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32mr.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32rm.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32rm.s
index 5d8a43d59967..b313c7538dbd 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32rm.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD32rm.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD_F32m.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD_F32m.s
index 3b9caa5e77bc..403473527a8e 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD_F32m.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-ADD_F32m.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-BEXTR32rm.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-BEXTR32rm.s
index f7c899f4108c..5913b8b59e9d 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-BEXTR32rm.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-BEXTR32rm.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-BSF16rm.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-BSF16rm.s
index bd79a7054826..a3f66f60e336 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-BSF16rm.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-BSF16rm.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-BTR64mr.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-BTR64mr.s
index 8c89a8e3cbc9..b4359952ff49 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-BTR64mr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-BTR64mr.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-CMOV16rm-noreg-serialization.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-CMOV16rm-noreg-serialization.s
index 1b0fe8c3a8b0..302c2b0ee722 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-CMOV16rm-noreg-serialization.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-CMOV16rm-noreg-serialization.s
@@ -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!
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-FLDENVm.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-FLDENVm.s
index 07aeed1b29e0..d81cdf5c8989 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-FLDENVm.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-FLDENVm.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-HLT.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-HLT.s
index 2b9a23e917b2..7503377c2e22 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-HLT.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-HLT.s
@@ -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.
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-LEA64r.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-LEA64r.s
index 057b156a009b..1a20bda3a361 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-LEA64r.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-LEA64r.s
@@ -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
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-POPCNT32rr.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-POPCNT32rr.s
index f59d5c2651f7..df211ff03992 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-POPCNT32rr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-POPCNT32rr.s
@@ -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
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-STD.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-STD.s
index 0757db9fc9a7..58748285bf83 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-STD.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-STD.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-VFMADDSS4rm.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-VFMADDSS4rm.s
index b4b5172d0f96..69a2b581bd32 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-VFMADDSS4rm.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-VFMADDSS4rm.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-XCHG64rr.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-XCHG64rr.s
index ad4868c3cd53..2bf539cd2210 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-XCHG64rr.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-XCHG64rr.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-by-opcode-name.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-by-opcode-name.s
index c751ef52707f..225587e1b31a 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-by-opcode-name.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-by-opcode-name.s
@@ -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:
diff --git a/llvm/test/tools/llvm-exegesis/X86/uops/uops-misspelled-div.s b/llvm/test/tools/llvm-exegesis/X86/uops/uops-misspelled-div.s
index 5e4a3040b2c5..7a3699b20068 100644
--- a/llvm/test/tools/llvm-exegesis/X86/uops/uops-misspelled-div.s
+++ b/llvm/test/tools/llvm-exegesis/X86/uops/uops-misspelled-div.s
@@ -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
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index f6db14f0e0a7..e71461b50a62 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -34,6 +34,13 @@ class Error;
namespace exegesis {
+enum class BenchmarkPhaseSelectorE {
+ StopBeforeAllCodegen,
+ StopBeforeFullCodegen,
+ StopBeforeMeasurements,
+ Measure,
+};
+
enum class InstructionBenchmarkFilter { All, RegOnly, WithMem };
struct InstructionBenchmarkKey {
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 37b33ae02113..9bd38e11c33b 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -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;
@@ -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())
@@ -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())
@@ -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));
@@ -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);
}
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
index e55e2e109105..ea60eee92339 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
@@ -36,7 +36,7 @@ class BenchmarkRunner {
public:
explicit BenchmarkRunner(const LLVMState &State,
InstructionBenchmark::ModeE Mode,
- bool BenchmarkSkipMeasurements);
+ BenchmarkPhaseSelectorE BenchmarkPhaseSelector);
virtual ~BenchmarkRunner();
@@ -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>>
diff --git a/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp
index e837bb1d5344..d57ee146d2a0 100644
--- a/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp
@@ -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");
diff --git a/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h
index 942cc8081bdb..d7d1fa96d20e 100644
--- a/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h
+++ b/llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.h
@@ -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;
diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp
index 8c6275bc7bd3..f22601546f0c 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -74,7 +74,7 @@ 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) {
@@ -82,7 +82,8 @@ ExegesisTarget::createBenchmarkRunner(
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";
@@ -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;
@@ -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,
diff --git a/llvm/tools/llvm-exegesis/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h
index 3d631b9375ea..c922228bfbb2 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.h
+++ b/llvm/tools/llvm-exegesis/lib/Target.h
@@ -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;
@@ -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;
diff --git a/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h
index f9e59264b834..c726944f4f5a 100644
--- a/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h
+++ b/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h
@@ -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;
diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
index aa7261f7e5a2..d0fb76ffc2a3 100644
--- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -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",
@@ -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 "
@@ -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");
}
More information about the llvm-commits
mailing list