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/MachineBlockPlacement.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'backend/lib/CodeGen/MachineBlockPlacement.cpp') diff --git a/backend/lib/CodeGen/MachineBlockPlacement.cpp b/backend/lib/CodeGen/MachineBlockPlacement.cpp index 1e563e1..8e2242c 100644 --- a/backend/lib/CodeGen/MachineBlockPlacement.cpp +++ b/backend/lib/CodeGen/MachineBlockPlacement.cpp @@ -51,11 +51,6 @@ enum class PlacementClass : std::uint8_t { return Contract; } -[[nodiscard]] Error prefixedError(const Error &Failure, std::string Prefix) { - Prefix.append(Failure.message()); - return Error(Failure.code(), std::move(Prefix)); -} - [[nodiscard]] PlacementClass classify(const MachineBasicBlock &Block, std::uint64_t Frequency) noexcept { const MachineBasicBlockAttributes &Attributes = Block.attributes(); @@ -112,7 +107,7 @@ MachineBlockPlacementPass::run(MachineFunction &Function, const TargetDescriptio Function, Target, MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); if (!Trial) - return std::unexpected(prefixedError(Trial.error(), "block placement setup failed: ")); + return std::unexpected(withErrorContext(Trial.error(), "block placement setup failed: ")); MachineFunctionAnalysisManager TrialAnalyses; MachineActionReplay Actions(Analyses, Trial->InstructionStableIDs); auto TrialResult = runImplementation(*Trial->ClonedFunction, Target, TrialAnalyses, Actions); @@ -121,7 +116,7 @@ MachineBlockPlacementPass::run(MachineFunction &Function, const TargetDescriptio Actions.beginReplay(); auto Result = runImplementation(Function, Target, Analyses, Actions); if (!Result) { - return std::unexpected(prefixedError( + return std::unexpected(withErrorContext( Result.error(), "block placement diverged after a successful transaction preflight: ")); } auto Replayed = Actions.finishReplay(); -- cgit v1.2.3