[llvm] [LLVM][MC] Add tracing support to llvm-mc to measure decode times (PR #151149)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 29 09:33:19 PDT 2025


================
@@ -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)) {
----------------
mshockwave wrote:

nit: I prefer to use a normal for-loop here as it doesn't seem to worth it to including a new header file.

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


More information about the llvm-commits mailing list