diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-28 13:45:07 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-28 13:45:07 +0800 |
| commit | e72ad2cd524ff38f162a23d69da5f78494d337ae (patch) | |
| tree | 2e590806b0f610e4392f25f6e8cdff57d2f5a929 /backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp | |
| parent | 3b14bd4d5324b5a280c1ee5567b5526b59e60c5b (diff) | |
| download | rcc-project-e72ad2cd524ff38f162a23d69da5f78494d337ae.tar.gz rcc-project-e72ad2cd524ff38f162a23d69da5f78494d337ae.tar.xz | |
[CodeGen] Centralize machine instruction erasure
Diffstat (limited to 'backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp')
| -rw-r--r-- | backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp index f87bb78..8361de2 100644 --- a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp +++ b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp @@ -707,11 +707,7 @@ private: auto Constraint = constrainSelectedInstruction(**Result, Function, Target); if (!Constraint) return std::unexpected(Constraint.error()); - MachineBasicBlock *Block = Instruction.parent(); - if (Block == nullptr) - return makeUnexpected(ErrorCode::InternalError, - "RISC-V global address is detached from its block"); - return Block->removeInstruction(Instruction); + return Instruction.eraseFromParent(); }; if (UseGOT) { @@ -781,11 +777,7 @@ private: auto LowConstraint = constrainSelectedInstruction(**Low, Function, Target); if (!LowConstraint) return std::unexpected(LowConstraint.error()); - MachineBasicBlock *Block = Instruction.parent(); - if (Block == nullptr) - return makeUnexpected(ErrorCode::InternalError, - "RISC-V global address is detached from its block"); - return Block->removeInstruction(Instruction); + return Instruction.eraseFromParent(); } [[nodiscard]] Expected<void> selectCopy(MachineInstr &Instruction, MachineFunction &Function, @@ -1107,11 +1099,7 @@ private: if (!Inverted) return std::unexpected(Inverted.error()); } - MachineBasicBlock *Block = Instruction.parent(); - if (Block == nullptr) - return makeUnexpected(ErrorCode::InternalError, - "RISC-V floating comparison is detached from its block"); - return Block->removeInstruction(Instruction); + return Instruction.eraseFromParent(); } [[nodiscard]] Expected<void> selectFence(MachineInstr &Instruction) const { |
