From 7819df7189a54fa5b8df657d10285f1873628d25 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Wed, 12 Aug 2026 01:07:48 +0800 Subject: [RISCV] Model FFLAGS accesses --- backend/lib/CodeGen/PostRAScheduler.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'backend/lib/CodeGen/PostRAScheduler.cpp') diff --git a/backend/lib/CodeGen/PostRAScheduler.cpp b/backend/lib/CodeGen/PostRAScheduler.cpp index 026f763..204f05e 100644 --- a/backend/lib/CodeGen/PostRAScheduler.cpp +++ b/backend/lib/CodeGen/PostRAScheduler.cpp @@ -130,6 +130,13 @@ void removeUnits(RegisterUnitLaneSet &Live, const std::vector Physical = Reg.physicalRegister(); + return Physical && (Function.registerInfo().isReserved(*Physical) || + Target.registers().isReservedRegister(*Physical)); +} + [[nodiscard]] OperandFlagUpdate &getFlagUpdate(std::vector &Updates, MachineOperand &Operand) { const auto Position = std::ranges::find_if( @@ -175,7 +182,7 @@ buildBlockLivenessRepairPlan(MachineBasicBlock &Block, const TargetDescription & auto Units = physicalOperandUnits(*Operand, Target); if (!Units) return std::unexpected(Units.error()); - if (!intersects(Live, *Units)) + if (!isReservedPhysicalRegister(*Reg, Block.function(), Target) && !intersects(Live, *Units)) Update.Flags.set(RegisterOperandFlag::Dead); } @@ -218,6 +225,8 @@ buildBlockLivenessRepairPlan(MachineBasicBlock &Block, const TargetDescription & const Register *Reg = Operand->getIf(); if (Reg == nullptr || Reg->isNoRegister()) continue; + if (isReservedPhysicalRegister(*Reg, Block.function(), Target)) + continue; auto Units = physicalOperandUnits(*Operand, Target); if (!Units) return std::unexpected(Units.error()); -- cgit v1.2.3