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/InstructionSelect.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/InstructionSelect.cpp')
| -rw-r--r-- | backend/lib/CodeGen/GlobalISel/InstructionSelect.cpp | 30 |
1 files changed, 4 insertions, 26 deletions
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 <algorithm> #include <cstdint> -#include <optional> #include <string> #include <unordered_set> #include <utility> @@ -214,33 +212,13 @@ Expected<MachinePassResult> 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<MachinePassResult> InstructionSelect::runImplementation(MachineFunction &Function, const TargetDescription &Target, - MachineActionReplay &Actions) { + MachineFunctionAnalysisManager + &Analyses) { MachinePassResult Result; std::vector<MachineInstr *> Worklist; @@ -304,7 +282,7 @@ Expected<MachinePassResult> 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) { |
