From e0c77d80585428818c32886eb8c26755ea8ed159 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 1 Aug 2026 18:17:33 +0800 Subject: [CodeGen] Track debug instruction identities Add monotonic MIR debug instruction numbers and structured value substitutions. Verify live number uniqueness, meta-instruction exclusion, substitution graph integrity, and target subregister references while preserving debug identities during cloning. --- backend/include/rcc/CodeGen/MachineInstr.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'backend/include/rcc/CodeGen/MachineInstr.h') diff --git a/backend/include/rcc/CodeGen/MachineInstr.h b/backend/include/rcc/CodeGen/MachineInstr.h index bcae306..78d48cb 100644 --- a/backend/include/rcc/CodeGen/MachineInstr.h +++ b/backend/include/rcc/CodeGen/MachineInstr.h @@ -9,6 +9,7 @@ #include "rcc/Support/Error.h" #include +#include #include #include #include @@ -132,6 +133,17 @@ public: Origin.reset(); } + [[nodiscard]] std::uint32_t debugInstrNumber() const noexcept { + return DebugInstrNumber; + } + + [[nodiscard]] Expected setDebugInstrNumber(std::uint64_t Number); + [[nodiscard]] Expected assignDebugInstrNumber(); + + void clearDebugInstrNumber() noexcept { + DebugInstrNumber = 0; + } + private: MachineInstr(MachineFunction &OwnerFunction, Opcode InstructionOpcode, MachineInstrStableID StableID); @@ -153,6 +165,7 @@ private: MachineInstrFlags Flags; std::optional Location; std::optional Origin; + std::uint32_t DebugInstrNumber = 0; friend class MachineArena; friend class MachineBasicBlock; -- cgit v1.2.3