[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
This commit is contained in:
Aiden Grossman authored and GitHub committed 2026-07-14 06:18:31 -07:00
1 parent c43967ca74
commit fb423ba07c
2 files changed
+14 -1

No files matched your search

+3 -1
View File
@@ -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();
@@ -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")