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/MachineFallthrough.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/MachineFallthrough.cpp')
| -rw-r--r-- | backend/lib/CodeGen/MachineFallthrough.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/backend/lib/CodeGen/MachineFallthrough.cpp b/backend/lib/CodeGen/MachineFallthrough.cpp index 608b703..3619155 100644 --- a/backend/lib/CodeGen/MachineFallthrough.cpp +++ b/backend/lib/CodeGen/MachineFallthrough.cpp @@ -36,11 +36,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]] Expected<std::vector<MachineBasicBlock *>> normalizeFallthroughs(MachineFunction &Function, const TargetDescription &Target, const TargetInstrInfo &Info) { @@ -129,7 +124,7 @@ Expected<MachinePassResult> MachineFallthroughPass::run(MachineFunction &Functio Function, Target, MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); if (!Trial) - return std::unexpected(prefixedError(Trial.error(), "fallthrough setup failed: ")); + return std::unexpected(withErrorContext(Trial.error(), "fallthrough setup failed: ")); MachineFunctionAnalysisManager TrialAnalyses; auto TrialLiveness = TrialAnalyses.getResult<LiveVariablesAnalysis>(*Trial->ClonedFunction, Target); @@ -147,8 +142,8 @@ Expected<MachinePassResult> MachineFallthroughPass::run(MachineFunction &Functio return std::unexpected(Liveness.error()); auto ChangedBlocks = normalizeFallthroughs(Function, Target, *Info); if (!ChangedBlocks) { - return std::unexpected(prefixedError(ChangedBlocks.error(), - "fallthrough diverged after a successful preflight: ")); + return std::unexpected(withErrorContext(ChangedBlocks.error(), + "fallthrough diverged after a successful preflight: ")); } auto Repaired = repairPostRAMachineBlockLiveness(*ChangedBlocks, Target, **Liveness); if (!Repaired) |
