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/lib/CodeGen/MachineFunction.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'backend/lib/CodeGen/MachineFunction.cpp') diff --git a/backend/lib/CodeGen/MachineFunction.cpp b/backend/lib/CodeGen/MachineFunction.cpp index 294158b..df1ceb5 100644 --- a/backend/lib/CodeGen/MachineFunction.cpp +++ b/backend/lib/CodeGen/MachineFunction.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -86,6 +87,19 @@ Expected MachineFunction::setTargetState(TargetFunctionState State) { return {}; } +Expected MachineFunction::allocateDebugInstrNumber() { + if (DebugInstrNumberingCount == std::numeric_limits::max()) { + return makeUnexpected(ErrorCode::InternalError, + "machine debug instruction number space is exhausted"); + } + ++DebugInstrNumberingCount; + return DebugInstrNumberingCount; +} + +void MachineFunction::observeDebugInstrNumber(std::uint32_t Number) noexcept { + DebugInstrNumberingCount = std::max(DebugInstrNumberingCount, Number); +} + Expected MachineFunction::createBasicBlock() { auto ID = BlockIDGenerator.allocate(); if (!ID) -- cgit v1.2.3