[llvm] [llvm-mc] Add --runs option for benchmarking (PR #151149)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 30 08:13:02 PDT 2025


https://github.com/jurahul updated https://github.com/llvm/llvm-project/pull/151149

>From 6c49bdd429968a7e59332e122fea5c0015cfa25b Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Sat, 21 Jun 2025 10:32:11 -0700
Subject: [PATCH 1/5] LLVM-MC profiling to measure disassembly times

---
 llvm/tools/llvm-mc/Disassembler.cpp | 49 +++++++++++++++++++----------
 llvm/tools/llvm-mc/Disassembler.h   |  3 +-
 llvm/tools/llvm-mc/llvm-mc.cpp      | 46 ++++++++++++++++++++++++---
 3 files changed, 76 insertions(+), 22 deletions(-)

diff --git a/llvm/tools/llvm-mc/Disassembler.cpp b/llvm/tools/llvm-mc/Disassembler.cpp
index 86727931067a5..00dee06e847ce 100644
--- a/llvm/tools/llvm-mc/Disassembler.cpp
+++ b/llvm/tools/llvm-mc/Disassembler.cpp
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Disassembler.h"
+#include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
@@ -24,6 +25,7 @@
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
 
@@ -32,24 +34,25 @@ using namespace llvm;
 typedef std::pair<std::vector<unsigned char>, std::vector<const char *>>
     ByteArrayTy;
 
-static bool PrintInsts(const MCDisassembler &DisAsm, const ByteArrayTy &Bytes,
+static bool printInsts(const MCDisassembler &DisAsm, const ByteArrayTy &Bytes,
                        SourceMgr &SM, MCStreamer &Streamer, bool InAtomicBlock,
-                       const MCSubtargetInfo &STI) {
+                       const MCSubtargetInfo &STI, unsigned BenchmarkNumRuns) {
   ArrayRef<uint8_t> Data(Bytes.first);
 
   // Disassemble it to strings.
   uint64_t Size;
-  uint64_t Index;
 
-  for (Index = 0; Index < Bytes.first.size(); Index += Size) {
-    MCInst Inst;
+  for (uint64_t Index = 0; Index < Bytes.first.size(); Index += Size) {
+    auto getInstruction = [&](MCInst &Inst) -> MCDisassembler::DecodeStatus {
+      if (STI.getTargetTriple().getArch() == Triple::hexagon)
+        return DisAsm.getInstructionBundle(Inst, Size, Data.slice(Index), Index,
+                                           nulls());
+      return DisAsm.getInstruction(Inst, Size, Data.slice(Index), Index,
+                                   nulls());
+    };
 
-    MCDisassembler::DecodeStatus S;
-    if (STI.getTargetTriple().getArch() == Triple::hexagon)
-      S = DisAsm.getInstructionBundle(Inst, Size, Data.slice(Index), Index,
-                                      nulls());
-    else
-      S = DisAsm.getInstruction(Inst, Size, Data.slice(Index), Index, nulls());
+    MCInst Inst;
+    MCDisassembler::DecodeStatus S = getInstruction(Inst);
     switch (S) {
     case MCDisassembler::Fail:
       SM.PrintMessage(SMLoc::getFromPointer(Bytes.second[Index]),
@@ -74,12 +77,24 @@ static bool PrintInsts(const MCDisassembler &DisAsm, const ByteArrayTy &Bytes,
       Streamer.emitInstruction(Inst, STI);
       break;
     }
+
+    if (S == MCDisassembler::Success && BenchmarkNumRuns != 0) {
+      // Benchmark mode, collect timing for decoding the instruction several
+      // times.
+      MCInst BMInst;
+      TimeTraceScope timeScope("getInstruction");
+      for (unsigned _ : llvm::seq<unsigned>(BenchmarkNumRuns)) {
+        BMInst.clear();
+        BMInst.setOpcode(0);
+        S = getInstruction(BMInst);
+      }
+    }
   }
 
   return false;
 }
 
-static bool SkipToToken(StringRef &Str) {
+static bool skipToToken(StringRef &Str) {
   for (;;) {
     if (Str.empty())
       return false;
@@ -101,7 +116,7 @@ static bool SkipToToken(StringRef &Str) {
 
 static bool byteArrayFromString(ByteArrayTy &ByteArray, StringRef &Str,
                                 SourceMgr &SM, bool HexBytes) {
-  while (SkipToToken(Str)) {
+  while (skipToToken(Str)) {
     // Handled by higher level
     if (Str[0] == '[' || Str[0] == ']')
       return false;
@@ -151,7 +166,7 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
                               MCSubtargetInfo &STI, MCStreamer &Streamer,
                               MemoryBuffer &Buffer, SourceMgr &SM,
                               MCContext &Ctx, const MCTargetOptions &MCOptions,
-                              bool HexBytes) {
+                              bool HexBytes, unsigned BenchmarkNumRuns) {
   std::unique_ptr<const MCRegisterInfo> MRI(T.createMCRegInfo(Triple));
   if (!MRI) {
     errs() << "error: no register info for target " << Triple << "\n";
@@ -179,7 +194,7 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
   StringRef Str = Buffer.getBuffer();
   bool InAtomicBlock = false;
 
-  while (SkipToToken(Str)) {
+  while (skipToToken(Str)) {
     ByteArray.first.clear();
     ByteArray.second.clear();
 
@@ -207,8 +222,8 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
     ErrorOccurred |= byteArrayFromString(ByteArray, Str, SM, HexBytes);
 
     if (!ByteArray.first.empty())
-      ErrorOccurred |=
-          PrintInsts(*DisAsm, ByteArray, SM, Streamer, InAtomicBlock, STI);
+      ErrorOccurred |= printInsts(*DisAsm, ByteArray, SM, Streamer,
+                                  InAtomicBlock, STI, BenchmarkNumRuns);
   }
 
   if (InAtomicBlock) {
diff --git a/llvm/tools/llvm-mc/Disassembler.h b/llvm/tools/llvm-mc/Disassembler.h
index 5efffca1e9926..334b72af8b522 100644
--- a/llvm/tools/llvm-mc/Disassembler.h
+++ b/llvm/tools/llvm-mc/Disassembler.h
@@ -32,7 +32,8 @@ class Disassembler {
   static int disassemble(const Target &T, const std::string &Triple,
                          MCSubtargetInfo &STI, MCStreamer &Streamer,
                          MemoryBuffer &Buffer, SourceMgr &SM, MCContext &Ctx,
-                         const MCTargetOptions &MCOptions, bool HexBytes);
+                         const MCTargetOptions &MCOptions, bool HexBytes,
+                         unsigned BenchmarkNumRuns);
 };
 
 } // namespace llvm
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index da89af71bbbe8..4f3ff1569c158 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Disassembler.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/DWARFCFIChecker/DWARFCFIFunctionFrameAnalyzer.h"
 #include "llvm/DWARFCFIChecker/DWARFCFIFunctionFrameStreamer.h"
 #include "llvm/MC/MCAsmBackend.h"
@@ -37,6 +38,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/TargetParser/Host.h"
@@ -240,6 +242,24 @@ static cl::opt<ActionType> Action(
                           "Colored disassembly of strings of hex bytes")),
     cl::cat(MCCategory));
 
+static cl::opt<unsigned>
+    BenchmarkNumRuns("benchmark-num-runs",
+                     cl::desc("Number of runs for decoder benchmarking"),
+                     cl::cat(MCCategory));
+
+static cl::opt<bool> TimeTrace("time-trace", cl::desc("Record time trace"));
+
+static cl::opt<unsigned> TimeTraceGranularity(
+    "time-trace-granularity",
+    cl::desc(
+        "Minimum time granularity (in microseconds) traced by time profiler"),
+    cl::init(500), cl::Hidden);
+
+static cl::opt<std::string>
+    TimeTraceFile("time-trace-file",
+                  cl::desc("Specify time trace file destination"),
+                  cl::value_desc("filename"));
+
 static const Target *GetTarget(const char *ProgName) {
   // Figure out the target triple.
   if (TripleName.empty())
@@ -371,6 +391,22 @@ int main(int argc, char **argv) {
 
   cl::HideUnrelatedOptions({&MCCategory, &getColorCategory()});
   cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
+
+  if (TimeTrace)
+    timeTraceProfilerInitialize(TimeTraceGranularity, argv[0]);
+
+  auto TimeTraceScopeExit = make_scope_exit([]() {
+    if (!TimeTrace)
+      return;
+    if (auto E = timeTraceProfilerWrite(TimeTraceFile, OutputFilename)) {
+      handleAllErrors(std::move(E), [&](const StringError &SE) {
+        errs() << SE.getMessage() << "\n";
+      });
+      return;
+    }
+    timeTraceProfilerCleanup();
+  });
+
   MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
   MCOptions.CompressDebugSections = CompressDebugSections.getValue();
   MCOptions.ShowMCInst = ShowInst;
@@ -603,7 +639,7 @@ int main(int argc, char **argv) {
   }
 
   int Res = 1;
-  bool disassemble = false;
+  bool Disassemble = false;
   switch (Action) {
   case AC_AsLex:
     Res = AsLexInput(SrcMgr, *MAI, Out->os());
@@ -615,12 +651,13 @@ int main(int argc, char **argv) {
   case AC_MDisassemble:
   case AC_CDisassemble:
   case AC_Disassemble:
-    disassemble = true;
+    Disassemble = true;
     break;
   }
-  if (disassemble)
+  if (Disassemble)
     Res = Disassembler::disassemble(*TheTarget, TripleName, *STI, *Str, *Buffer,
-                                    SrcMgr, Ctx, MCOptions, HexBytes);
+                                    SrcMgr, Ctx, MCOptions, HexBytes,
+                                    BenchmarkNumRuns);
 
   // Keep output if no errors.
   if (Res == 0) {
@@ -628,5 +665,6 @@ int main(int argc, char **argv) {
     if (DwoOut)
       DwoOut->keep();
   }
+
   return Res;
 }

>From 36687cab05d9ffbebb183269707c79c03ca4edd8 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Tue, 29 Jul 2025 10:25:08 -0700
Subject: [PATCH 2/5] Review feedback

---
 llvm/tools/llvm-mc/Disassembler.cpp | 39 ++++++++++++++++-------------
 llvm/tools/llvm-mc/Disassembler.h   |  2 +-
 llvm/tools/llvm-mc/llvm-mc.cpp      | 14 +++++------
 3 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/llvm/tools/llvm-mc/Disassembler.cpp b/llvm/tools/llvm-mc/Disassembler.cpp
index 00dee06e847ce..2ee422126dbfb 100644
--- a/llvm/tools/llvm-mc/Disassembler.cpp
+++ b/llvm/tools/llvm-mc/Disassembler.cpp
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "Disassembler.h"
-#include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
@@ -34,25 +33,29 @@ using namespace llvm;
 typedef std::pair<std::vector<unsigned char>, std::vector<const char *>>
     ByteArrayTy;
 
+static MCDisassembler::DecodeStatus getInstruction(const MCDisassembler &DisAsm,
+                                                   const MCSubtargetInfo &STI,
+                                                   MCInst &Inst, uint64_t &Size,
+                                                   ArrayRef<uint8_t> Bytes,
+                                                   uint64_t Address) {
+  if (STI.getTargetTriple().getArch() == Triple::hexagon)
+    return DisAsm.getInstructionBundle(Inst, Size, Bytes, Address, nulls());
+  return DisAsm.getInstruction(Inst, Size, Bytes, Address, nulls());
+}
+
 static bool printInsts(const MCDisassembler &DisAsm, const ByteArrayTy &Bytes,
                        SourceMgr &SM, MCStreamer &Streamer, bool InAtomicBlock,
-                       const MCSubtargetInfo &STI, unsigned BenchmarkNumRuns) {
+                       const MCSubtargetInfo &STI, unsigned NumBenchmarkRuns) {
   ArrayRef<uint8_t> Data(Bytes.first);
 
   // Disassemble it to strings.
   uint64_t Size;
 
   for (uint64_t Index = 0; Index < Bytes.first.size(); Index += Size) {
-    auto getInstruction = [&](MCInst &Inst) -> MCDisassembler::DecodeStatus {
-      if (STI.getTargetTriple().getArch() == Triple::hexagon)
-        return DisAsm.getInstructionBundle(Inst, Size, Data.slice(Index), Index,
-                                           nulls());
-      return DisAsm.getInstruction(Inst, Size, Data.slice(Index), Index,
-                                   nulls());
-    };
 
     MCInst Inst;
-    MCDisassembler::DecodeStatus S = getInstruction(Inst);
+    MCDisassembler::DecodeStatus S =
+        getInstruction(DisAsm, STI, Inst, Size, Data.slice(Index), Index);
     switch (S) {
     case MCDisassembler::Fail:
       SM.PrintMessage(SMLoc::getFromPointer(Bytes.second[Index]),
@@ -78,15 +81,15 @@ static bool printInsts(const MCDisassembler &DisAsm, const ByteArrayTy &Bytes,
       break;
     }
 
-    if (S == MCDisassembler::Success && BenchmarkNumRuns != 0) {
+    if (S == MCDisassembler::Success && NumBenchmarkRuns != 0) {
       // Benchmark mode, collect timing for decoding the instruction several
       // times.
       MCInst BMInst;
       TimeTraceScope timeScope("getInstruction");
-      for (unsigned _ : llvm::seq<unsigned>(BenchmarkNumRuns)) {
+      for (unsigned I = 0; I < NumBenchmarkRuns; ++I) {
         BMInst.clear();
         BMInst.setOpcode(0);
-        S = getInstruction(BMInst);
+        S = getInstruction(DisAsm, STI, BMInst, Size, Data.slice(Index), Index);
       }
     }
   }
@@ -94,7 +97,7 @@ static bool printInsts(const MCDisassembler &DisAsm, const ByteArrayTy &Bytes,
   return false;
 }
 
-static bool skipToToken(StringRef &Str) {
+static bool SkipToToken(StringRef &Str) {
   for (;;) {
     if (Str.empty())
       return false;
@@ -116,7 +119,7 @@ static bool skipToToken(StringRef &Str) {
 
 static bool byteArrayFromString(ByteArrayTy &ByteArray, StringRef &Str,
                                 SourceMgr &SM, bool HexBytes) {
-  while (skipToToken(Str)) {
+  while (SkipToToken(Str)) {
     // Handled by higher level
     if (Str[0] == '[' || Str[0] == ']')
       return false;
@@ -166,7 +169,7 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
                               MCSubtargetInfo &STI, MCStreamer &Streamer,
                               MemoryBuffer &Buffer, SourceMgr &SM,
                               MCContext &Ctx, const MCTargetOptions &MCOptions,
-                              bool HexBytes, unsigned BenchmarkNumRuns) {
+                              bool HexBytes, unsigned NumBenchmarkRuns) {
   std::unique_ptr<const MCRegisterInfo> MRI(T.createMCRegInfo(Triple));
   if (!MRI) {
     errs() << "error: no register info for target " << Triple << "\n";
@@ -194,7 +197,7 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
   StringRef Str = Buffer.getBuffer();
   bool InAtomicBlock = false;
 
-  while (skipToToken(Str)) {
+  while (SkipToToken(Str)) {
     ByteArray.first.clear();
     ByteArray.second.clear();
 
@@ -223,7 +226,7 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
 
     if (!ByteArray.first.empty())
       ErrorOccurred |= printInsts(*DisAsm, ByteArray, SM, Streamer,
-                                  InAtomicBlock, STI, BenchmarkNumRuns);
+                                  InAtomicBlock, STI, NumBenchmarkRuns);
   }
 
   if (InAtomicBlock) {
diff --git a/llvm/tools/llvm-mc/Disassembler.h b/llvm/tools/llvm-mc/Disassembler.h
index 334b72af8b522..5ee47d54200be 100644
--- a/llvm/tools/llvm-mc/Disassembler.h
+++ b/llvm/tools/llvm-mc/Disassembler.h
@@ -33,7 +33,7 @@ class Disassembler {
                          MCSubtargetInfo &STI, MCStreamer &Streamer,
                          MemoryBuffer &Buffer, SourceMgr &SM, MCContext &Ctx,
                          const MCTargetOptions &MCOptions, bool HexBytes,
-                         unsigned BenchmarkNumRuns);
+                         unsigned NumBenchmarkRuns);
 };
 
 } // namespace llvm
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index 4f3ff1569c158..4f446eae36164 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -243,7 +243,7 @@ static cl::opt<ActionType> Action(
     cl::cat(MCCategory));
 
 static cl::opt<unsigned>
-    BenchmarkNumRuns("benchmark-num-runs",
+    NumBenchmarkRuns("num-benchmark-runs",
                      cl::desc("Number of runs for decoder benchmarking"),
                      cl::cat(MCCategory));
 
@@ -399,9 +399,7 @@ int main(int argc, char **argv) {
     if (!TimeTrace)
       return;
     if (auto E = timeTraceProfilerWrite(TimeTraceFile, OutputFilename)) {
-      handleAllErrors(std::move(E), [&](const StringError &SE) {
-        errs() << SE.getMessage() << "\n";
-      });
+      logAllUnhandledErrors(std::move(E), errs());
       return;
     }
     timeTraceProfilerCleanup();
@@ -639,7 +637,7 @@ int main(int argc, char **argv) {
   }
 
   int Res = 1;
-  bool Disassemble = false;
+  bool disassemble = false;
   switch (Action) {
   case AC_AsLex:
     Res = AsLexInput(SrcMgr, *MAI, Out->os());
@@ -651,13 +649,13 @@ int main(int argc, char **argv) {
   case AC_MDisassemble:
   case AC_CDisassemble:
   case AC_Disassemble:
-    Disassemble = true;
+    disassemble = true;
     break;
   }
-  if (Disassemble)
+  if (disassemble)
     Res = Disassembler::disassemble(*TheTarget, TripleName, *STI, *Str, *Buffer,
                                     SrcMgr, Ctx, MCOptions, HexBytes,
-                                    BenchmarkNumRuns);
+                                    NumBenchmarkRuns);
 
   // Keep output if no errors.
   if (Res == 0) {

>From 9465d4205999ce1d8aaa0c3eef6a37afc1bbf1a0 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Tue, 29 Jul 2025 16:58:46 -0700
Subject: [PATCH 3/5] Add simple uuit test

---
 llvm/test/tools/llvm-mc/disassembler-profile.test | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 llvm/test/tools/llvm-mc/disassembler-profile.test

diff --git a/llvm/test/tools/llvm-mc/disassembler-profile.test b/llvm/test/tools/llvm-mc/disassembler-profile.test
new file mode 100644
index 0000000000000..3808562b1eb32
--- /dev/null
+++ b/llvm/test/tools/llvm-mc/disassembler-profile.test
@@ -0,0 +1,12 @@
+# REQUIRES: aarch64-registered-target
+# RUN: rm -rf %t.json
+# RUN: llvm-mc -arch aarch64 -disassemble -o /dev/null %s -num-benchmark-runs=1000 -time-trace -time-trace-file=%t.json
+# RUN: FileCheck --input-file %t.json %s
+
+# Note: Test input taken from llvm/test/MC/Disassembler/AArch64/udf.txt
+
+# CHECK: "name":"Total getInstruction"
+# CHECK: "args":{"count":3,"avg ms":{{.*}}}
+[0x00,0x00,0x00,0x00]
+[0x01,0x02,0x00,0x00]
+[0xff,0xff,0x00,0x00]
\ No newline at end of file

>From de073902b07afdf65cdbe7ebde95554b8f835116 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Tue, 29 Jul 2025 17:01:05 -0700
Subject: [PATCH 4/5] Newline at end of file

---
 llvm/test/tools/llvm-mc/disassembler-profile.test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/tools/llvm-mc/disassembler-profile.test b/llvm/test/tools/llvm-mc/disassembler-profile.test
index 3808562b1eb32..2e631ac28cbcf 100644
--- a/llvm/test/tools/llvm-mc/disassembler-profile.test
+++ b/llvm/test/tools/llvm-mc/disassembler-profile.test
@@ -9,4 +9,4 @@
 # CHECK: "args":{"count":3,"avg ms":{{.*}}}
 [0x00,0x00,0x00,0x00]
 [0x01,0x02,0x00,0x00]
-[0xff,0xff,0x00,0x00]
\ No newline at end of file
+[0xff,0xff,0x00,0x00]

>From e1b8ebf99d1d9a26123db5be302a06c4aaa40f0c Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 30 Jul 2025 08:12:11 -0700
Subject: [PATCH 5/5] Additional review feedback

---
 .../tools/llvm-mc/disassembler-profile.test   | 24 +++++++++----------
 llvm/tools/llvm-mc/llvm-mc.cpp                |  3 +--
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/llvm/test/tools/llvm-mc/disassembler-profile.test b/llvm/test/tools/llvm-mc/disassembler-profile.test
index 2e631ac28cbcf..67afdce3a5423 100644
--- a/llvm/test/tools/llvm-mc/disassembler-profile.test
+++ b/llvm/test/tools/llvm-mc/disassembler-profile.test
@@ -1,12 +1,12 @@
-# REQUIRES: aarch64-registered-target
-# RUN: rm -rf %t.json
-# RUN: llvm-mc -arch aarch64 -disassemble -o /dev/null %s -num-benchmark-runs=1000 -time-trace -time-trace-file=%t.json
-# RUN: FileCheck --input-file %t.json %s
-
-# Note: Test input taken from llvm/test/MC/Disassembler/AArch64/udf.txt
-
-# CHECK: "name":"Total getInstruction"
-# CHECK: "args":{"count":3,"avg ms":{{.*}}}
-[0x00,0x00,0x00,0x00]
-[0x01,0x02,0x00,0x00]
-[0xff,0xff,0x00,0x00]
+# REQUIRES: aarch64-registered-target
+# RUN: rm -rf %t.json
+# RUN: llvm-mc -triple=aarch64 -disassemble -o /dev/null %s -runs=1000 -time-trace -time-trace-file=%t.json
+# RUN: FileCheck --input-file %t.json %s
+
+# Note: Test input taken from llvm/test/MC/Disassembler/AArch64/udf.txt
+
+# CHECK: "name":"Total getInstruction"
+# CHECK: "args":{"count":3,"avg ms":{{.*}}}
+[0x00,0x00,0x00,0x00]
+[0x01,0x02,0x00,0x00]
+[0xff,0xff,0x00,0x00]
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index 4f446eae36164..f69f7c725c6b4 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -243,8 +243,7 @@ static cl::opt<ActionType> Action(
     cl::cat(MCCategory));
 
 static cl::opt<unsigned>
-    NumBenchmarkRuns("num-benchmark-runs",
-                     cl::desc("Number of runs for decoder benchmarking"),
+    NumBenchmarkRuns("runs", cl::desc("Number of runs for benchmarking"),
                      cl::cat(MCCategory));
 
 static cl::opt<bool> TimeTrace("time-trace", cl::desc("Record time trace"));



More information about the llvm-commits mailing list