aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/CodeGen/MachineDCE.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 22:05:14 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 22:05:14 +0800
commit3a57627e59ba18b6f9f9aae7bb60c390c0d3575a (patch)
tree736ca062bfffbd68177a512dfe145b06c16d11b1 /backend/lib/CodeGen/MachineDCE.cpp
parent379ff50dcc7ccf977379aee68fa9d10f69065d23 (diff)
downloadrcc-project-3a57627e59ba18b6f9f9aae7bb60c390c0d3575a.tar.gz
rcc-project-3a57627e59ba18b6f9f9aae7bb60c390c0d3575a.tar.xz
[MC] Implement RV64GC object emission
Diffstat (limited to 'backend/lib/CodeGen/MachineDCE.cpp')
-rw-r--r--backend/lib/CodeGen/MachineDCE.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/backend/lib/CodeGen/MachineDCE.cpp b/backend/lib/CodeGen/MachineDCE.cpp
index b413499..9ba9a1b 100644
--- a/backend/lib/CodeGen/MachineDCE.cpp
+++ b/backend/lib/CodeGen/MachineDCE.cpp
@@ -44,7 +44,9 @@ namespace {
}
[[nodiscard]] bool hasProtectedAttachment(const MachineInstr &Instruction) noexcept {
- return Instruction.debugInstrNumber() != 0 || Instruction.preInstrSymbol().has_value() ||
+ return Instruction.flags().has(MachineInstrFlag::FrameSetup) ||
+ Instruction.flags().has(MachineInstrFlag::FrameDestroy) ||
+ Instruction.debugInstrNumber() != 0 || Instruction.preInstrSymbol().has_value() ||
Instruction.postInstrSymbol().has_value() || Instruction.heapAllocMarker().has_value() ||
Instruction.pcSections().has_value() || Instruction.mmra().has_value() ||
Instruction.cfiType().has_value() || Instruction.deactivationSymbol().has_value();
@@ -156,8 +158,10 @@ Expected<MachinePassResult> MachineDCEPass::runImplementation(MachineFunction &F
Instruction = Next;
continue;
}
+ std::vector<Register> DefinitionList =
+ std::move(*Definitions).value_or(std::vector<Register>{});
- for (const Register Reg : **Definitions) {
+ for (const Register Reg : DefinitionList) {
auto Cleared = clearDebugUses(Registers, Reg);
if (!Cleared)
return std::unexpected(Cleared.error());
@@ -165,7 +169,7 @@ Expected<MachinePassResult> MachineDCEPass::runImplementation(MachineFunction &F
auto Removed = Block->removeInstruction(*Instruction);
if (!Removed)
return std::unexpected(Removed.error());
- for (const Register Reg : **Definitions) {
+ for (const Register Reg : DefinitionList) {
if (!Registers.useEmpty(Reg, true) || Registers.getUniqueVRegDef(Reg) != nullptr) {
return makeUnexpected(ErrorCode::InternalError,
"machine DCE left references to a removed definition");