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/MachineCopyPropagation.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/MachineCopyPropagation.cpp')
| -rw-r--r-- | backend/lib/CodeGen/MachineCopyPropagation.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/backend/lib/CodeGen/MachineCopyPropagation.cpp b/backend/lib/CodeGen/MachineCopyPropagation.cpp index 9725399..2c4cc44 100644 --- a/backend/lib/CodeGen/MachineCopyPropagation.cpp +++ b/backend/lib/CodeGen/MachineCopyPropagation.cpp @@ -62,11 +62,6 @@ copyPropagationContract(MachineCopyPropagationStage Stage) { return Stage == MachineCopyPropagationStage::PreRegisterAllocation ? PreRA : PostRA; } -[[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.debugInstrNumber() != 0 || Instruction.preInstrSymbol().has_value() || Instruction.postInstrSymbol().has_value() || Instruction.heapAllocMarker().has_value() || @@ -302,7 +297,7 @@ MachineCopyPropagationPass::run(MachineFunction &Function, const TargetDescripti MachineFunctionCloneOptions{.NewStableID = Function.stableID(), .NewName = std::nullopt}); if (!Trial) { return std::unexpected( - prefixedError(Trial.error(), "COPY propagation transaction setup failed: ")); + withErrorContext(Trial.error(), "COPY propagation transaction setup failed: ")); } MachineActionReplay Actions(Analyses, Trial->InstructionStableIDs); auto TrialResult = runImplementation(*Trial->ClonedFunction, Target, Actions); @@ -311,7 +306,7 @@ MachineCopyPropagationPass::run(MachineFunction &Function, const TargetDescripti Actions.beginReplay(); auto Result = runImplementation(Function, Target, Actions); if (!Result) { - return std::unexpected(prefixedError( + return std::unexpected(withErrorContext( Result.error(), "COPY propagation diverged after a successful transaction preflight: ")); } auto Replayed = Actions.finishReplay(); |
