[llvm] d2bcd58 - [profdata] Consume reader error if returned early (#163671)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 27 12:44:04 PDT 2025


Author: Ellis Hoag
Date: 2025-10-27T12:43:59-07:00
New Revision: d2bcd58aa6d9d49af9129537d837c87bb491d99d

URL: https://github.com/llvm/llvm-project/commit/d2bcd58aa6d9d49af9129537d837c87bb491d99d
DIFF: https://github.com/llvm/llvm-project/commit/d2bcd58aa6d9d49af9129537d837c87bb491d99d.diff

LOG: [profdata] Consume reader error if returned early (#163671)

Added: 
    

Modified: 
    llvm/tools/llvm-profdata/llvm-profdata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index a356bcd0773e0..9b853e29592b4 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,12 @@ loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
   // we have more non-fatal errors from InstrProfReader in the future. How
   // should this interact with 
diff erent -failure-mode?
   std::optional<std::pair<Error, std::string>> ReaderWarning;
+  auto ReaderWarningScope = llvm::make_scope_exit([&] {
+    // If we hit a 
diff erent error we may still have an error in ReaderWarning.
+    // Consume it now to avoid an assert
+    if (ReaderWarning)
+      consumeError(std::move(ReaderWarning->first));
+  });
   auto Warn = [&](Error E) {
     if (ReaderWarning) {
       consumeError(std::move(E));


        


More information about the llvm-commits mailing list