From a47055fe6af27de9d1ce505938e0cebbca5532ff Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Wed, 26 Aug 2026 23:43:44 +0800 Subject: [CodeGen] Remove transactional register allocation --- backend/lib/CodeGen/RegAllocFast.cpp | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) (limited to 'backend/lib/CodeGen/RegAllocFast.cpp') diff --git a/backend/lib/CodeGen/RegAllocFast.cpp b/backend/lib/CodeGen/RegAllocFast.cpp index 9448558..eca9494 100644 --- a/backend/lib/CodeGen/RegAllocFast.cpp +++ b/backend/lib/CodeGen/RegAllocFast.cpp @@ -11,7 +11,6 @@ #include "rcc/CodeGen/MachineInstr.h" #include "rcc/CodeGen/MachineOperand.h" #include "rcc/CodeGen/MachineRegisterInfo.h" -#include "rcc/CodeGen/Spiller.h" #include #include @@ -571,43 +570,18 @@ Expected FastAllocatorPass::run(MachineFunction &Function, MachineFunctionAnalysisManager &Analyses) { if (Info == nullptr) return makeUnexpected(ErrorCode::InvalidArgument, "FastAllocator requires target behavior"); - auto Trial = regalloc_detail::cloneForAllocation(Function, Target); - if (!Trial) - return std::unexpected(Trial.error()); const std::vector FunctionReserved = regalloc_detail::functionReservedRegisters(Function, Target, *Info); - auto TrialReserved = - regalloc_detail::reserveFunctionRegisters(*Trial->ClonedFunction, FunctionReserved); - if (!TrialReserved) - return std::unexpected(TrialReserved.error()); - MachineFunctionAnalysisManager TrialAnalyses; - auto Registered = registerStage11MachineAnalyses(TrialAnalyses); - if (!Registered) - return std::unexpected(Registered.error()); - auto TrialLiveness = - TrialAnalyses.getResult(*Trial->ClonedFunction, Target); - if (!TrialLiveness) - return std::unexpected(TrialLiveness.error()); - FastAllocatorEngine TrialAllocator(*Trial->ClonedFunction, Target, *Info, **TrialLiveness); - auto TrialRun = TrialAllocator.run(); - if (!TrialRun) - return std::unexpected(TrialRun.error()); - auto TrialVerification = - regalloc_detail::verifyAllocationTrial(*Trial->ClonedFunction, Target, contract()); - if (!TrialVerification) - return std::unexpected(TrialVerification.error()); + auto Reserved = regalloc_detail::reserveFunctionRegisters(Function, FunctionReserved); + if (!Reserved) + return std::unexpected(Reserved.error()); auto Liveness = Analyses.getResult(Function, Target); if (!Liveness) return std::unexpected(Liveness.error()); FastAllocatorEngine Allocator(Function, Target, *Info, **Liveness); auto Allocated = Allocator.run(); - if (!Allocated) { - return std::unexpected(withErrorContext( - Allocated.error(), "FastAllocator diverged after a successful transaction preflight: ")); - } - auto Reserved = regalloc_detail::reserveFunctionRegisters(Function, FunctionReserved); - if (!Reserved) - return std::unexpected(Reserved.error()); + if (!Allocated) + return std::unexpected(Allocated.error()); Allocated->Changed |= *Reserved; return regalloc_detail::passResult(*Allocated); } -- cgit v1.2.3