diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-22 18:59:22 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-22 18:59:22 +0800 |
| commit | 36b0be1ec1558f88d4f031a1817c3a4c2cba07a6 (patch) | |
| tree | 3cf29b19ec7e450bd04dca8d416d68350aa20de2 /backend/lib/CodeGen/MachineInstr.cpp | |
| parent | 8a4bb6e3b0bffa0ed79b51347b12ee4293b622a7 (diff) | |
| download | rcc-project-36b0be1ec1558f88d4f031a1817c3a4c2cba07a6.tar.gz rcc-project-36b0be1ec1558f88d4f031a1817c3a4c2cba07a6.tar.xz | |
[CodeGen] Match LLVM machine debug stripping
Diffstat (limited to 'backend/lib/CodeGen/MachineInstr.cpp')
| -rw-r--r-- | backend/lib/CodeGen/MachineInstr.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/backend/lib/CodeGen/MachineInstr.cpp b/backend/lib/CodeGen/MachineInstr.cpp index f4602e0..55b4ce9 100644 --- a/backend/lib/CodeGen/MachineInstr.cpp +++ b/backend/lib/CodeGen/MachineInstr.cpp @@ -2,6 +2,7 @@ #include "rcc/CodeGen/MachineInstr.h" +#include "rcc/CodeGen/GenericOpcodes.h" #include "rcc/CodeGen/MachineBasicBlock.h" #include "rcc/CodeGen/MachineFunction.h" #include "rcc/CodeGen/MachineMemOperand.h" @@ -18,6 +19,14 @@ namespace rcc { +bool MachineInstr::isDebugInstr() const noexcept { + return InstructionOpcode == rcc::opcode(GenericOpcode::DBG_VALUE) || + InstructionOpcode == rcc::opcode(GenericOpcode::DBG_VALUE_LIST) || + InstructionOpcode == rcc::opcode(GenericOpcode::DBG_LABEL) || + InstructionOpcode == rcc::opcode(GenericOpcode::DBG_INSTR_REF) || + InstructionOpcode == rcc::opcode(GenericOpcode::DBG_PHI); +} + MachineInstr::MachineInstr(MachineFunction &OwnerFunction, Opcode InstructionOpcode, MachineInstrStableID StableID) : OwnerFunction(&OwnerFunction), InstructionOpcode(InstructionOpcode), StableID(StableID) {} @@ -97,6 +106,13 @@ Expected<void> MachineInstr::insertOperand(std::size_t Index, MachineOperand &&O return makeUnexpected(ErrorCode::InvalidArgument, "register operand references an unknown virtual register"); } + if (Operand.isUse() && isDebugInstr()) { + RegisterOperandFlags RegisterFlags = Operand.registerFlags(); + RegisterFlags.set(RegisterOperandFlag::Debug); + auto Updated = Operand.setRegisterFlags(RegisterFlags); + if (!Updated) + return std::unexpected(Updated.error()); + } Operands.insert(Operands.begin() + static_cast<std::ptrdiff_t>(Index), std::move(Operand)); adjustTiesForInsertion(Index); |
