[llvm] 90b2048 - bitcode: Improve invalid summary version error (#204888)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 19 15:34:44 PDT 2026


Author: Matt Arsenault
Date: 2026-06-20T00:34:40+02:00
New Revision: 90b204888de4da58d4f3b68355658c16a14a1e46

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

LOG: bitcode: Improve invalid summary version error (#204888)

Added: 
    llvm/test/Bitcode/Inputs/invalid-summary-version.bc
    llvm/test/Bitcode/invalid-summary-version.test

Modified: 
    llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 3e8cbc1a2a2f7..c913dd811a2e0 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -7756,10 +7756,9 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
   // corresponding function summary.
   const bool MemProfAfterFunctionSummary = Version >= 13;
   if (Version < 1 || Version > ModuleSummaryIndex::BitcodeSummaryVersion)
-    return error("Invalid summary version " + Twine(Version) +
-                 ". Version should be in the range [1-" +
-                 Twine(ModuleSummaryIndex::BitcodeSummaryVersion) +
-                 "].");
+    return error("Invalid summary version " + Twine(Version) + " in module '" +
+                 ModulePath + "'. Version should be in the range [1-" +
+                 Twine(ModuleSummaryIndex::BitcodeSummaryVersion) + "].");
   Record.clear();
 
   // Keep around the last seen summary to be used when we see an optional

diff  --git a/llvm/test/Bitcode/Inputs/invalid-summary-version.bc b/llvm/test/Bitcode/Inputs/invalid-summary-version.bc
new file mode 100644
index 0000000000000..c68d3a7fa9110
Binary files /dev/null and b/llvm/test/Bitcode/Inputs/invalid-summary-version.bc 
diff er

diff  --git a/llvm/test/Bitcode/invalid-summary-version.test b/llvm/test/Bitcode/invalid-summary-version.test
new file mode 100644
index 0000000000000..bd9be816fb6e1
--- /dev/null
+++ b/llvm/test/Bitcode/invalid-summary-version.test
@@ -0,0 +1,5 @@
+; Test that an invalid summary version error includes the module name.
+RUN: not llvm-lto --thinlto-index-stats %p/Inputs/invalid-summary-version.bc 2>&1 | \
+RUN:   FileCheck %s
+
+CHECK: Invalid summary version {{[0-9]+}} in module '{{.*}}invalid-summary-version.bc'. Version should be in the range [1-{{[0-9]+}}].


        


More information about the llvm-commits mailing list