[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
================
@@ -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 {
----------------
mshockwave wrote:
I'm not sure if defining a lambda in a loop is a good idea. IIRC all the captures will be placed in an implicit object, so putting lambda definition in a loop with capture would result in repeatedly storing captured variables into an object on the stack, which is not necessarily better than simply passing the variable you want to capture through lambda's function argument
https://github.com/llvm/llvm-project/pull/151149
More information about the llvm-commits
mailing list