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 --- .../lib/CodeGen/GlobalISel/InstructionSelect.cpp | 30 +++------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp') diff --git a/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp index 66bbff2..6aab43d 100644 --- a/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -6,14 +6,12 @@ #include "rcc/CodeGen/GlobalISel/Utils.h" #include "rcc/CodeGen/MachineBasicBlock.h" #include "rcc/CodeGen/MachineFunction.h" -#include "rcc/CodeGen/MachineFunctionCloner.h" #include "rcc/CodeGen/MachineInstr.h" #include "rcc/CodeGen/MachineRegisterInfo.h" #include "rcc/CodeGen/TargetDescription.h" #include #include -#include #include #include #include @@ -214,33 +212,13 @@ Expected InstructionSelect::run(MachineFunction &Function, if (Info == nullptr) return std::unexpected(passFailure("instruction select has no target behavior interface", ErrorCode::InvalidArgument)); - auto Trial = cloneMachineFunction( - Function, Target, - MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); - if (!Trial) { - return std::unexpected( - withErrorContext(Trial.error(), "instruction-selection transaction setup 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(), - "instruction selection diverged after a successful transaction preflight: ")); - } - auto Replayed = Actions.finishReplay(); - if (!Replayed) - return std::unexpected(Replayed.error()); - return Result; + return runImplementation(Function, Target, Analyses); } Expected InstructionSelect::runImplementation(MachineFunction &Function, const TargetDescription &Target, - MachineActionReplay &Actions) { + MachineFunctionAnalysisManager + &Analyses) { MachinePassResult Result; std::vector Worklist; @@ -304,7 +282,7 @@ Expected InstructionSelect::runImplementation(MachineFunction return std::unexpected(Match.error()); std::string Rule = "select."; Rule.append(CurrentDescriptor->Name); - auto Accepted = Actions.request(Rule, Function, Instruction->stableID()); + auto Accepted = Analyses.requestAction(Rule, Function, Instruction->stableID()); if (!Accepted) return std::unexpected(Accepted.error()); if (!*Accepted) { -- cgit v1.2.3