diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-26 23:33:07 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-26 23:33:07 +0800 |
| commit | 27c303ff00234e5ab9379878858f7ae3d0bdc2dc (patch) | |
| tree | 49639bc910abe9999f07d044ec235ce17dec3ca4 /backend/lib/CodeGen/GlobalISel/Combiner.cpp | |
| parent | a72a7a4323fb6eef8e15cc2f1229bcca14879e94 (diff) | |
| download | rcc-project-27c303ff00234e5ab9379878858f7ae3d0bdc2dc.tar.gz rcc-project-27c303ff00234e5ab9379878858f7ae3d0bdc2dc.tar.xz | |
[GlobalISel] Run machine transformations once
Diffstat (limited to 'backend/lib/CodeGen/GlobalISel/Combiner.cpp')
| -rw-r--r-- | backend/lib/CodeGen/GlobalISel/Combiner.cpp | 27 |
1 files changed, 4 insertions, 23 deletions
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 <optional> #include <string> namespace rcc { @@ -21,31 +19,13 @@ const MachinePassContract &GlobalISelCombinerPass::contract() const noexcept { Expected<MachinePassResult> 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<MachinePassResult> 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) { |
