aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/CodeGen/TwoAddressInstructionPass.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-28 13:45:07 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-28 13:45:07 +0800
commite72ad2cd524ff38f162a23d69da5f78494d337ae (patch)
tree2e590806b0f610e4392f25f6e8cdff57d2f5a929 /backend/lib/CodeGen/TwoAddressInstructionPass.cpp
parent3b14bd4d5324b5a280c1ee5567b5526b59e60c5b (diff)
downloadrcc-project-e72ad2cd524ff38f162a23d69da5f78494d337ae.tar.gz
rcc-project-e72ad2cd524ff38f162a23d69da5f78494d337ae.tar.xz
[CodeGen] Centralize machine instruction erasure
Diffstat (limited to 'backend/lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r--backend/lib/CodeGen/TwoAddressInstructionPass.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/backend/lib/CodeGen/TwoAddressInstructionPass.cpp b/backend/lib/CodeGen/TwoAddressInstructionPass.cpp
index 80da2e8..d7a5ef1 100644
--- a/backend/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/backend/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -175,13 +175,6 @@ buildImplicitDef(MachineFunction &Function, const TargetDescription &Target,
return *Composed;
}
-[[nodiscard]] Expected<void> removeInstruction(MachineInstr &Instruction) {
- MachineBasicBlock *Block = Instruction.parent();
- if (Block == nullptr)
- return makeUnexpected(ErrorCode::InternalError, "rewritten instruction is not linked");
- return Block->removeInstruction(Instruction);
-}
-
[[nodiscard]] Expected<void> expandRegSequence(MachineInstr &Instruction, MachineFunction &Function,
const TargetDescription &Target,
const TargetInstrInfo &TargetInfo) {
@@ -240,7 +233,7 @@ buildImplicitDef(MachineFunction &Function, const TargetDescription &Target,
if (!Copy)
return std::unexpected(Copy.error());
}
- return removeInstruction(Instruction);
+ return Instruction.eraseFromParent();
}
[[nodiscard]] Expected<void> expandInsertSubreg(MachineInstr &Instruction,
@@ -309,7 +302,7 @@ buildImplicitDef(MachineFunction &Function, const TargetDescription &Target,
if (!Copy)
return std::unexpected(Copy.error());
}
- return removeInstruction(Instruction);
+ return Instruction.eraseFromParent();
}
[[nodiscard]] Expected<void> swapRegisterUses(MachineOperand &Left, MachineOperand &Right) {
@@ -450,9 +443,10 @@ TwoAddressInstructionPass::run(MachineFunction &Function, const TargetDescriptio
return runImplementation(Function, Target, Analyses);
}
-Expected<MachinePassResult> TwoAddressInstructionPass::runImplementation(
- MachineFunction &Function, const TargetDescription &Target,
- MachineFunctionAnalysisManager &Analyses) {
+Expected<MachinePassResult>
+TwoAddressInstructionPass::runImplementation(MachineFunction &Function,
+ const TargetDescription &Target,
+ MachineFunctionAnalysisManager &Analyses) {
MachinePassResult Result;
const std::vector<MachineInstr *> Instructions(Function.allInstructions().begin(),
Function.allInstructions().end());