From 8558f80b4077536d6aa46b97328d6df1210e261f Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Thu, 13 Aug 2026 13:18:05 +0800 Subject: [Support] Centralize error context handling --- backend/lib/CodeGen/PostRAScheduler.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'backend/lib/CodeGen/PostRAScheduler.cpp') diff --git a/backend/lib/CodeGen/PostRAScheduler.cpp b/backend/lib/CodeGen/PostRAScheduler.cpp index b5f7ae9..fede8df 100644 --- a/backend/lib/CodeGen/PostRAScheduler.cpp +++ b/backend/lib/CodeGen/PostRAScheduler.cpp @@ -49,11 +49,6 @@ namespace { return Contract; } -[[nodiscard]] Error prefixedError(const Error &Failure, std::string Prefix) { - Prefix.append(Failure.message()); - return Error(Failure.code(), std::move(Prefix)); -} - } // namespace const MachinePassContract &PostRASchedulerPass::contract() const noexcept { @@ -72,7 +67,7 @@ Expected PostRASchedulerPass::run(MachineFunction &Function, MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); if (!Trial) { return std::unexpected( - prefixedError(Trial.error(), "post-RA scheduler transaction setup failed: ")); + withErrorContext(Trial.error(), "post-RA scheduler transaction setup failed: ")); } MachineFunctionAnalysisManager TrialAnalyses; auto TrialLiveness = @@ -104,7 +99,7 @@ Expected PostRASchedulerPass::run(MachineFunction &Function, auto Run = runMachineScheduler(Function, Target, *Model, ScheduleDAGMode::PostRegisterAllocation, **Liveness, **Frequencies, Options, &Actions); if (!Run) { - return std::unexpected(prefixedError( + return std::unexpected(withErrorContext( Run.error(), "post-RA scheduler diverged after a successful transaction preflight: ")); } auto Replayed = Actions.finishReplay(); -- cgit v1.2.3