[llvm] [llvm-mca] Add optional identifier field to mca::Instruction (PR #97867)
Chinmay Deshpande via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 16:15:57 PDT 2024
https://github.com/chinmaydd created https://github.com/llvm/llvm-project/pull/97867
While using llvm-mca as a library (in MCA Daemon), we've been having trouble uniquely identifying instructions that go through the pipeline. Inspired by the discussion [here](https://github.com/llvm/llvm-project/pull/92849#discussion_r1621376233), I believe it may make sense to add an optional identifier to each `mca::Instruction`.
A possible instance of use could be the `InstrBuilder` incrementing the `Identifier` by 1 after each instruction is created. I'm happy to add that too.
>From f44dd7f93a17b3ebde1f0353a0fab972b163cdc6 Mon Sep 17 00:00:00 2001
From: Chinmay Deshpande <cddeshpa at uci.edu>
Date: Fri, 5 Jul 2024 16:05:25 -0700
Subject: [PATCH] [llvm-mca] Add optional identifier field to mca::Instruction
---
llvm/include/llvm/MCA/Instruction.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/include/llvm/MCA/Instruction.h b/llvm/include/llvm/MCA/Instruction.h
index e48a70164bec6..09822e43a827d 100644
--- a/llvm/include/llvm/MCA/Instruction.h
+++ b/llvm/include/llvm/MCA/Instruction.h
@@ -643,6 +643,8 @@ class Instruction : public InstructionBase {
// True if this instruction has been optimized at register renaming stage.
bool IsEliminated;
+ std::optional<uint64_t> Identifier;
+
public:
Instruction(const InstrDesc &D, const unsigned Opcode)
: InstructionBase(D, Opcode), Stage(IS_INVALID),
@@ -690,6 +692,9 @@ class Instruction : public InstructionBase {
bool isRetired() const { return Stage == IS_RETIRED; }
bool isEliminated() const { return IsEliminated; }
+ std::optional<uint64_t> getIdentifier() const { return Identifier; }
+ void setIdentifier(uint64_t Id) { Identifier = Id; }
+
// Forces a transition from state IS_DISPATCHED to state IS_EXECUTED.
void forceExecuted();
void setEliminated() { IsEliminated = true; }
More information about the llvm-commits
mailing list