From 27c303ff00234e5ab9379878858f7ae3d0bdc2dc Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Wed, 26 Aug 2026 23:33:07 +0800 Subject: [GlobalISel] Run machine transformations once --- backend/lib/CodeGen/GlobalISel/Combiner.cpp | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'backend/lib/CodeGen/GlobalISel/Combiner.cpp') diff --git a/backend/lib/CodeGen/GlobalISel/Combiner.cpp b/backend/lib/CodeGen/GlobalISel/Combiner.cpp index 08b471a..c0a92cc 100644 --- a/backend/lib/CodeGen/GlobalISel/Combiner.cpp +++ b/backend/lib/CodeGen/GlobalISel/Combiner.cpp @@ -6,10 +6,8 @@ #include "rcc/CodeGen/LiveVariables.h" #include "rcc/CodeGen/MachineBasicBlock.h" #include "rcc/CodeGen/MachineFunction.h" -#include "rcc/CodeGen/MachineFunctionCloner.h" #include "rcc/CodeGen/MachineInstr.h" -#include #include namespace rcc { @@ -21,31 +19,13 @@ const MachinePassContract &GlobalISelCombinerPass::contract() const noexcept { Expected GlobalISelCombinerPass::run(MachineFunction &Function, const TargetDescription &Target, MachineFunctionAnalysisManager &Analyses) { - auto Trial = cloneMachineFunction( - Function, Target, - MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); - if (!Trial) - return std::unexpected(withErrorContext(Trial.error(), "GlobalISel combiner clone failed: ")); - - MachineActionReplay Actions(Analyses, Trial->InstructionStableIDs); - auto TrialResult = runImplementation(*Trial->ClonedFunction, Target, Actions); - if (!TrialResult) - return std::unexpected(TrialResult.error()); - Actions.beginReplay(); - auto Result = runImplementation(Function, Target, Actions); - if (!Result) - return std::unexpected( - withErrorContext(Result.error(), "GlobalISel combiner replay diverged: ")); - auto Replayed = Actions.finishReplay(); - if (!Replayed) - return std::unexpected(Replayed.error()); - return Result; + return runImplementation(Function, Target, Analyses); } Expected GlobalISelCombinerPass::runImplementation(MachineFunction &Function, const TargetDescription &Target, - MachineActionReplay &Actions) const { + MachineFunctionAnalysisManager &Analyses) const { if (MaximumRewrites == 0 || MaximumIterations == 0) return makeUnexpected(ErrorCode::InvalidArgument, "GlobalISel combiner iteration limits must be nonzero"); @@ -61,7 +41,8 @@ GlobalISelCombinerPass::runImplementation(MachineFunction &Function, if (!Matches) return std::unexpected(Matches.error()); if (*Matches && Rewrites < MaximumRewrites) { - auto Accepted = Actions.request("gisel-combiner", Function, Instruction->stableID()); + auto Accepted = + Analyses.requestAction("gisel-combiner", Function, Instruction->stableID()); if (!Accepted) return std::unexpected(Accepted.error()); if (*Accepted) { -- cgit v1.2.3