aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backend/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--backend/lib/CodeGen/MachineInstr.cpp16
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);