diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-26 23:43:44 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-26 23:43:44 +0800 |
| commit | a47055fe6af27de9d1ce505938e0cebbca5532ff (patch) | |
| tree | 2de32b198f57408e52e7a226a548e54e418b512c /backend/lib/CodeGen/RegAllocBasic.cpp | |
| parent | 35f4e0a3aa03dfae06b5c9f226e38e609de2eef5 (diff) | |
| download | rcc-project-a47055fe6af27de9d1ce505938e0cebbca5532ff.tar.gz rcc-project-a47055fe6af27de9d1ce505938e0cebbca5532ff.tar.xz | |
[CodeGen] Remove transactional register allocation
Diffstat (limited to 'backend/lib/CodeGen/RegAllocBasic.cpp')
| -rw-r--r-- | backend/lib/CodeGen/RegAllocBasic.cpp | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/backend/lib/CodeGen/RegAllocBasic.cpp b/backend/lib/CodeGen/RegAllocBasic.cpp index 5cb5035..8acfa5b 100644 --- a/backend/lib/CodeGen/RegAllocBasic.cpp +++ b/backend/lib/CodeGen/RegAllocBasic.cpp @@ -5,7 +5,6 @@ #include "RegAllocBase.h" #include "rcc/CodeGen/LiveIntervals.h" #include "rcc/CodeGen/LiveRegMatrix.h" -#include "rcc/CodeGen/LiveVariables.h" #include <algorithm> #include <memory> @@ -101,41 +100,18 @@ Expected<MachinePassResult> BasicAllocatorPass::run(MachineFunction &Function, MachineFunctionAnalysisManager &Analyses) { if (Info == nullptr) return makeUnexpected(ErrorCode::InvalidArgument, "BasicAllocator requires target behavior"); - auto Trial = regalloc_detail::cloneForAllocation(Function, Target); - if (!Trial) - return std::unexpected(Trial.error()); const std::vector<PhysicalRegister> 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()); - BasicAllocatorEngine TrialAllocator(*Trial->ClonedFunction, Target, *Info, TrialAnalyses, - Options); - VirtRegMap TrialMapping(*Trial->ClonedFunction); - auto TrialRun = TrialAllocator.run(TrialMapping); - 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()); BasicAllocatorEngine Allocator(Function, Target, *Info, Analyses, Options); auto Mapping = Analyses.getResult<VirtRegMapAnalysis>(Function, Target); if (!Mapping) return std::unexpected(Mapping.error()); auto Allocated = Allocator.run(**Mapping); - if (!Allocated) { - return std::unexpected(withErrorContext( - Allocated.error(), "BasicAllocator 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; MachinePassResult Result = regalloc_detail::passResult(*Allocated); Result.Preserved.preserve<VirtRegMapAnalysis>(); |
