diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-25 03:11:23 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-25 03:11:23 +0800 |
| commit | f5d9ddc085055d28d6f9fb3730c3566097f43fb2 (patch) | |
| tree | d1ca89a409a0d1a167e79e3d1693c22bcfd823a9 /backend/lib/CodeGen/RegAllocBasic.cpp | |
| parent | c3932f55208e3fe2019d26a0e5af421c0b644872 (diff) | |
| download | rcc-project-f5d9ddc085055d28d6f9fb3730c3566097f43fb2.tar.gz rcc-project-f5d9ddc085055d28d6f9fb3730c3566097f43fb2.tar.xz | |
[CodeGen] Implement the greedy register allocator pipeline
Diffstat (limited to 'backend/lib/CodeGen/RegAllocBasic.cpp')
| -rw-r--r-- | backend/lib/CodeGen/RegAllocBasic.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/backend/lib/CodeGen/RegAllocBasic.cpp b/backend/lib/CodeGen/RegAllocBasic.cpp index c3ed98b..2e2222f 100644 --- a/backend/lib/CodeGen/RegAllocBasic.cpp +++ b/backend/lib/CodeGen/RegAllocBasic.cpp @@ -78,10 +78,11 @@ private: .Requires = {MachineFunctionProperty::Selected, MachineFunctionProperty::NoPHIs, MachineFunctionProperty::TiedOpsRewritten, MachineFunctionProperty::TracksLiveness}, - .Sets = {MachineFunctionProperty::NoVRegs}, - .Clears = {}, - .RequiredAnalyses = {MachineFunctionAnalysisManager::id<LiveIntervalsAnalysis>()}, - .VerificationStage = PipelineStage::RegisterAllocated, + .Sets = {}, + .Clears = {MachineFunctionProperty::IsSSA}, + .RequiredAnalyses = {MachineFunctionAnalysisManager::id<LiveIntervalsAnalysis>(), + MachineFunctionAnalysisManager::id<VirtRegMapAnalysis>()}, + .VerificationStage = std::nullopt, }; Value.ThreadSafety = PassThreadSafety::ThreadSafe; return Value; @@ -118,7 +119,8 @@ Expected<MachinePassResult> BasicAllocatorPass::run(MachineFunction &Function, return std::unexpected(Registered.error()); BasicAllocatorEngine TrialAllocator(*Trial->ClonedFunction, Target, *Info, TrialAnalyses, Options); - auto TrialRun = TrialAllocator.run(); + VirtRegMap TrialMapping(*Trial->ClonedFunction); + auto TrialRun = TrialAllocator.run(TrialMapping); if (!TrialRun) return std::unexpected(TrialRun.error()); auto TrialVerification = @@ -126,7 +128,10 @@ Expected<MachinePassResult> BasicAllocatorPass::run(MachineFunction &Function, if (!TrialVerification) return std::unexpected(TrialVerification.error()); BasicAllocatorEngine Allocator(Function, Target, *Info, Analyses, Options); - auto Allocated = Allocator.run(); + 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: ")); @@ -135,7 +140,9 @@ Expected<MachinePassResult> BasicAllocatorPass::run(MachineFunction &Function, if (!Reserved) return std::unexpected(Reserved.error()); Allocated->Changed |= *Reserved; - return regalloc_detail::passResult(*Allocated); + MachinePassResult Result = regalloc_detail::passResult(*Allocated); + Result.Preserved.preserve<VirtRegMapAnalysis>(); + return Result; } std::unique_ptr<MachineFunctionPass> |
