diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-12 01:22:08 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-12 01:22:08 +0800 |
| commit | 0e43f63ac7fa5e28497760a0dfec2fe20557bce0 (patch) | |
| tree | b3279773b3f84dda8853be185a5af18f6938bddd /backend/lib/CodeGen/MachineLiveness.cpp | |
| parent | 785805863cbee537ba1e963ff177265171801aeb (diff) | |
| download | rcc-project-0e43f63ac7fa5e28497760a0dfec2fe20557bce0.tar.gz rcc-project-0e43f63ac7fa5e28497760a0dfec2fe20557bce0.tar.xz | |
[CodeGen] Track reserved register defs precisely
Diffstat (limited to 'backend/lib/CodeGen/MachineLiveness.cpp')
| -rw-r--r-- | backend/lib/CodeGen/MachineLiveness.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/backend/lib/CodeGen/MachineLiveness.cpp b/backend/lib/CodeGen/MachineLiveness.cpp index 528a675..7984e7d 100644 --- a/backend/lib/CodeGen/MachineLiveness.cpp +++ b/backend/lib/CodeGen/MachineLiveness.cpp @@ -846,11 +846,10 @@ struct LivenessRebuildPlan final { std::vector<OperandFlagPlan> Operands; }; -[[nodiscard]] Expected<bool> liveSetIntersects(const MachineOperand &Operand, - const RegisterLaneSet &Virtual, - const RegisterUnitLaneSet &Physical, - const MachineFunction &Function, - const TargetDescription &Target) { +[[nodiscard]] Expected<bool> +liveSetIntersects(const MachineOperand &Operand, const RegisterLaneSet &Virtual, + const RegisterUnitLaneSet &Physical, const MachineFunction &Function, + const TargetDescription &Target, bool TreatReservedAsLive) { const Register *Reg = Operand.getIf<Register>(); if (Reg == nullptr || Reg->isNoRegister()) return false; @@ -860,7 +859,7 @@ struct LivenessRebuildPlan final { return std::unexpected(Lanes.error()); return Virtual.intersects(*Reg, *Lanes); } - if (isReservedPhysicalRegister(*Reg, Function, Target)) + if (TreatReservedAsLive && isReservedPhysicalRegister(*Reg, Function, Target)) return true; auto Units = physicalOperandUnits(Operand, Target); if (!Units) @@ -947,7 +946,7 @@ buildLivenessRebuildPlan(const MachineFunction &Function, const TargetDescriptio const MachineOperand *Operand = Instruction->operandAt(Index); if (Operand == nullptr || !Operand->isRegister() || !Operand->isDef()) continue; - auto IsLive = liveSetIntersects(*Operand, Virtual, Physical, Function, Target); + auto IsLive = liveSetIntersects(*Operand, Virtual, Physical, Function, Target, false); if (!IsLive) return std::unexpected(IsLive.error()); RegisterOperandFlags Flags = Operand->registerFlags(); @@ -1003,7 +1002,7 @@ buildLivenessRebuildPlan(const MachineFunction &Function, const TargetDescriptio !Operand->registerValue()->isNoRegister(); bool IsKill = false; if (IsSemanticUse) { - auto IsLive = liveSetIntersects(*Operand, Virtual, Physical, Function, Target); + auto IsLive = liveSetIntersects(*Operand, Virtual, Physical, Function, Target, true); if (!IsLive) return std::unexpected(IsLive.error()); IsKill = !*IsLive; |
