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/MachineStackSlotColoring.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'backend/lib/CodeGen/MachineStackSlotColoring.cpp') diff --git a/backend/lib/CodeGen/MachineStackSlotColoring.cpp b/backend/lib/CodeGen/MachineStackSlotColoring.cpp index 005872b..7a65eb3 100644 --- a/backend/lib/CodeGen/MachineStackSlotColoring.cpp +++ b/backend/lib/CodeGen/MachineStackSlotColoring.cpp @@ -41,11 +41,6 @@ namespace { return Contract; } -[[nodiscard]] Error prefixedError(const Error &Failure, std::string Prefix) { - Prefix.append(Failure.message()); - return Error(Failure.code(), std::move(Prefix)); -} - struct SlotInterval final { MachineBasicBlock *Block = nullptr; std::size_t First = 0; @@ -242,14 +237,14 @@ Expected MachineStackSlotColoringPass::run(MachineFunction &F MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); if (!Trial) { return std::unexpected( - prefixedError(Trial.error(), "stack-slot coloring transaction setup failed: ")); + withErrorContext(Trial.error(), "stack-slot coloring transaction setup failed: ")); } auto TrialResult = runImplementation(*Trial->ClonedFunction); if (!TrialResult) return std::unexpected(TrialResult.error()); auto Result = runImplementation(Function); if (!Result) { - return std::unexpected(prefixedError( + return std::unexpected(withErrorContext( Result.error(), "stack-slot coloring diverged after a successful transaction preflight: ")); } return Result; -- cgit v1.2.3