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/MachineDCE.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/MachineDCE.cpp')
| -rw-r--r-- | backend/lib/CodeGen/MachineDCE.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/backend/lib/CodeGen/MachineDCE.cpp b/backend/lib/CodeGen/MachineDCE.cpp index 1c53c31..87c15d9 100644 --- a/backend/lib/CodeGen/MachineDCE.cpp +++ b/backend/lib/CodeGen/MachineDCE.cpp @@ -38,11 +38,6 @@ namespace { return Contract; } -[[nodiscard]] Error prefixedError(const Error &Failure, std::string Prefix) { - Prefix.append(Failure.message()); - return Error(Failure.code(), std::move(Prefix)); -} - [[nodiscard]] bool hasProtectedAttachment(const MachineInstr &Instruction) noexcept { return Instruction.flags().has(MachineInstrFlag::FrameSetup) || Instruction.flags().has(MachineInstrFlag::FrameDestroy) || @@ -125,7 +120,8 @@ Expected<MachinePassResult> MachineDCEPass::run(MachineFunction &Function, Function, Target, MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); if (!Trial) { - return std::unexpected(prefixedError(Trial.error(), "machine DCE transaction setup failed: ")); + return std::unexpected( + withErrorContext(Trial.error(), "machine DCE transaction setup failed: ")); } auto TrialResult = runImplementation(*Trial->ClonedFunction, Target); if (!TrialResult) @@ -133,7 +129,7 @@ Expected<MachinePassResult> MachineDCEPass::run(MachineFunction &Function, auto Result = runImplementation(Function, Target); if (!Result) { - return std::unexpected(prefixedError( + return std::unexpected(withErrorContext( Result.error(), "machine DCE diverged after a successful transaction preflight: ")); } return Result; |
