diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-13 13:18:05 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-13 13:18:05 +0800 |
| commit | 8558f80b4077536d6aa46b97328d6df1210e261f (patch) | |
| tree | 373a2242db00ddeb9a1af83dbd853e97e0bd12d3 /backend/lib/CodeGen/MachinePseudoExpansion.cpp | |
| parent | 65321c12beb31c5743e0cf3f28e7aec178b730a2 (diff) | |
| download | rcc-project-8558f80b4077536d6aa46b97328d6df1210e261f.tar.gz rcc-project-8558f80b4077536d6aa46b97328d6df1210e261f.tar.xz | |
[Support] Centralize error context handling
Diffstat (limited to 'backend/lib/CodeGen/MachinePseudoExpansion.cpp')
| -rw-r--r-- | backend/lib/CodeGen/MachinePseudoExpansion.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/backend/lib/CodeGen/MachinePseudoExpansion.cpp b/backend/lib/CodeGen/MachinePseudoExpansion.cpp index 663b148..e3109ed 100644 --- a/backend/lib/CodeGen/MachinePseudoExpansion.cpp +++ b/backend/lib/CodeGen/MachinePseudoExpansion.cpp @@ -195,11 +195,6 @@ using BlockSizeSnapshot = std::vector<std::pair<MachineBlockStableID, std::uint6 return TargetLate; } -[[nodiscard]] Error prefixedError(const Error &Failure, std::string Prefix) { - Prefix.append(Failure.message()); - return Error(Failure.code(), std::move(Prefix)); -} - [[nodiscard]] std::vector<MachineInstr *> layoutInstructions(MachineFunction &Function) { std::vector<MachineInstr *> Result; for (MachineBasicBlock *Block = Function.firstBlock(); Block != nullptr; Block = Block->next()) @@ -361,7 +356,7 @@ runPreparationTransaction(MachineFunction &Function, const TargetDescription &Ta Function, Target, MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); if (!Trial) - return std::unexpected(prefixedError(Trial.error(), "pseudo preparation setup failed: ")); + return std::unexpected(withErrorContext(Trial.error(), "pseudo preparation setup failed: ")); MachineActionReplay Actions(Analyses, Trial->InstructionStableIDs); auto TrialResult = prepareImplementation(*Trial->ClonedFunction, Target, Info, Actions); if (!TrialResult) @@ -369,8 +364,8 @@ runPreparationTransaction(MachineFunction &Function, const TargetDescription &Ta Actions.beginReplay(); auto Result = prepareImplementation(Function, Target, Info, Actions); if (!Result) { - return std::unexpected( - prefixedError(Result.error(), "pseudo preparation diverged after successful preflight: ")); + return std::unexpected(withErrorContext( + Result.error(), "pseudo preparation diverged after successful preflight: ")); } auto Replayed = Actions.finishReplay(); if (!Replayed) @@ -387,7 +382,7 @@ runExpansionTransaction(MachineFunction &Function, const TargetDescription &Targ Function, Target, MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); if (!Trial) - return std::unexpected(prefixedError(Trial.error(), "pseudo expansion setup failed: ")); + return std::unexpected(withErrorContext(Trial.error(), "pseudo expansion setup failed: ")); MachineActionReplay Actions(Analyses, Trial->InstructionStableIDs); auto TrialResult = expandImplementation(*Trial->ClonedFunction, Target, Info, Phase, BranchInfo, Actions); @@ -397,7 +392,7 @@ runExpansionTransaction(MachineFunction &Function, const TargetDescription &Targ auto Result = expandImplementation(Function, Target, Info, Phase, BranchInfo, Actions); if (!Result) { return std::unexpected( - prefixedError(Result.error(), "pseudo expansion diverged after successful preflight: ")); + withErrorContext(Result.error(), "pseudo expansion diverged after successful preflight: ")); } auto Replayed = Actions.finishReplay(); if (!Replayed) |
