From 1b4601c1ac91a06091610e969e70bcd1cb014cc5 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Mon, 24 Aug 2026 18:13:23 +0800 Subject: [RISCV] Match LLVM large call frame lowering --- backend/lib/CodeGen/LiveVariables.cpp | 20 ++++++++++++-------- backend/lib/CodeGen/MIRPrinter.cpp | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'backend/lib/CodeGen') diff --git a/backend/lib/CodeGen/LiveVariables.cpp b/backend/lib/CodeGen/LiveVariables.cpp index 201e09e..8bdd23e 100644 --- a/backend/lib/CodeGen/LiveVariables.cpp +++ b/backend/lib/CodeGen/LiveVariables.cpp @@ -441,10 +441,11 @@ struct LivenessRebuildPlan final { std::vector Operands; }; -[[nodiscard]] Expected -liveSetIntersects(const MachineOperand &Operand, const RegisterLaneSet &Virtual, - const LiveRegUnits &Physical, const MachineFunction &Function, - const TargetDescription &Target, bool TreatReservedAsLive) { +[[nodiscard]] Expected liveSetIntersects(const MachineOperand &Operand, + const RegisterLaneSet &Virtual, + const LiveRegUnits &Physical, + const MachineFunction &Function, + const TargetDescription &Target) { const Register *Reg = Operand.getIf(); if (Reg == nullptr || Reg->isNoRegister()) return false; @@ -454,8 +455,6 @@ liveSetIntersects(const MachineOperand &Operand, const RegisterLaneSet &Virtual, return std::unexpected(Lanes.error()); return Virtual.intersects(*Reg, *Lanes); } - if (TreatReservedAsLive && isReservedPhysicalRegister(*Reg, Function, Target)) - return true; auto Units = physicalOperandUnits(Operand, Target); if (!Units) return std::unexpected(Units.error()); @@ -546,6 +545,11 @@ liveSetIntersects(const MachineOperand &Operand, const RegisterLaneSet &Virtual, for (const MachineOperand &Operand : Instruction->operands()) { if (!Operand.isRegister() || !Operand.isUse()) continue; + const Register *Reg = Operand.getIf(); + if (Reg != nullptr && Reg->isPhysical() && + isReservedPhysicalRegister(*Reg, Function, Target)) { + continue; + } auto Added = addOperandToLiveSet(Operand, Virtual, Physical, Function, Target); if (!Added) return std::unexpected(Added.error()); @@ -600,7 +604,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, false); + auto IsLive = liveSetIntersects(*Operand, Virtual, Physical, Function, Target); if (!IsLive) return std::unexpected(IsLive.error()); RegisterOperandFlags Flags = Operand->registerFlags(); @@ -656,7 +660,7 @@ buildLivenessRebuildPlan(const MachineFunction &Function, const TargetDescriptio !Operand->registerValue()->isNoRegister(); bool IsKill = false; if (IsSemanticUse) { - auto IsLive = liveSetIntersects(*Operand, Virtual, Physical, Function, Target, true); + auto IsLive = liveSetIntersects(*Operand, Virtual, Physical, Function, Target); if (!IsLive) return std::unexpected(IsLive.error()); IsKill = !*IsLive; diff --git a/backend/lib/CodeGen/MIRPrinter.cpp b/backend/lib/CodeGen/MIRPrinter.cpp index 4683a81..3708053 100644 --- a/backend/lib/CodeGen/MIRPrinter.cpp +++ b/backend/lib/CodeGen/MIRPrinter.cpp @@ -1530,7 +1530,7 @@ namespace { [[nodiscard]] std::string hexadecimalWords(std::span Words, std::uint32_t BitWidth) { - constexpr std::string_view Hex = "0123456789ABCDEF"; + constexpr std::string_view Hex = "0123456789abcdef"; const std::size_t DigitCount = (static_cast(BitWidth) + 3U) / 4U; std::string Result(DigitCount, '0'); for (std::size_t Digit = 0; Digit < DigitCount; ++Digit) { -- cgit v1.2.3