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/MachineBlockPlacement.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/MachineBlockPlacement.cpp')
| -rw-r--r-- | backend/lib/CodeGen/MachineBlockPlacement.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
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(); |
