From f8d6f056b20558e05faab7a070f2ae60643685e3 Mon Sep 17 00:00:00 2001 From: Ellis Hoag Date: Wed, 15 Oct 2025 17:57:15 -0700 Subject: [PATCH 1/2] [profdata] Consume reader error if returned early --- llvm/tools/llvm-profdata/llvm-profdata.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 15ddb05f953ee..7be3fcf475a94 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -778,6 +779,10 @@ loadInput(const WeightedFile &Input, SymbolRemapper *Remapper, // we have more non-fatal errors from InstrProfReader in the future. How // should this interact with different -failure-mode? std::optional> ReaderWarning; + auto ReaderWarningScope = llvm::make_scope_exit([&] { + if (ReaderWarning) + consumeError(std::move(ReaderWarning->first)); + }); auto Warn = [&](Error E) { if (ReaderWarning) { consumeError(std::move(E)); From 68fa9c45f10b13f079a204723407470cba6aa73e Mon Sep 17 00:00:00 2001 From: Ellis Hoag Date: Wed, 15 Oct 2025 18:03:20 -0700 Subject: [PATCH 2/2] add comment --- llvm/tools/llvm-profdata/llvm-profdata.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 7be3fcf475a94..585a39de9985f 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -780,6 +780,8 @@ loadInput(const WeightedFile &Input, SymbolRemapper *Remapper, // should this interact with different -failure-mode? std::optional> ReaderWarning; auto ReaderWarningScope = llvm::make_scope_exit([&] { + // If we hit a different error we may still have an error in ReaderWarning. + // Consume it now to avoid an assert if (ReaderWarning) consumeError(std::move(ReaderWarning->first)); });