[llvm] fb423ba - [ThinLTO] Error on missing ValueInfo for function definition

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 06:18:36 PDT 2026


Author: Aiden Grossman
Date: 2026-07-14T06:18:31-07:00
New Revision: fb423ba07c3ff51fda3caa41d8bbb78d50f61906

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

LOG: [ThinLTO] Error on missing ValueInfo for function definition

We assume that these are available inside of BitcodeWriter
https://github.com/llvm/llvm-project/blob/09796808802f99c30a23bc0f2cd68243764e84ab/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp#L4927,
but do not currently validate this in input IR. This means that when
doing reductions with automated tooling in a non-asserts build, it is
pretty easy to end up with invalid IR that is not caught as invalid.

Reviewers: teresajohnson, mtrofin

Pull Request: https://github.com/llvm/llvm-project/pull/208948

Added: 
    llvm/test/Assembler/thinlto-bad-summary-5.ll

Modified: 
    llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index a6e7941a06699..f4ce522c23b8e 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -4924,7 +4924,9 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() {
     if (!VI || VI.getSummaryList().empty()) {
       // Only declarations should not have a summary (a declaration might
       // however have a summary if the def was in module level asm).
-      assert(F.isDeclaration());
+      if (!F.isDeclaration())
+        reportFatalUsageError("expected function definition " + F.getName() +
+                              " to have an associated value info.");
       continue;
     }
     auto *Summary = VI.getSummaryList()[0].get();

diff  --git a/llvm/test/Assembler/thinlto-bad-summary-5.ll b/llvm/test/Assembler/thinlto-bad-summary-5.ll
new file mode 100644
index 0000000000000..27ed18ad211fc
--- /dev/null
+++ b/llvm/test/Assembler/thinlto-bad-summary-5.ll
@@ -0,0 +1,11 @@
+; Test that we get an appropriate error when parsing a summary that does
+; not have value info associated with a function definition.
+
+; RUN: not llvm-as %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: expected function definition foo to have an associated value info.
+
+define void @foo() {
+  ret void
+}
+^1 = gv: (name: "foo")


        


More information about the llvm-commits mailing list