[llvm] [ThinLTO] Error on missing ValueInfo for function definition (PR #208948)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 11 13:09:31 PDT 2026
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/208948
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.
>From 1cdd33a4ed3311f549e297800c9226aaff5d413c Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sat, 11 Jul 2026 20:09:18 +0000
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.7
---
llvm/lib/AsmParser/LLParser.cpp | 14 ++++++++++++++
llvm/test/Assembler/thinlto-bad-summary-5.ll | 11 +++++++++++
2 files changed, 25 insertions(+)
create mode 100644 llvm/test/Assembler/thinlto-bad-summary-5.ll
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 38d10587b104e..a08dbc9c34b11 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -516,6 +516,20 @@ bool LLParser::validateEndOfIndex() {
"use of undefined type id summary '^" +
Twine(ForwardRefTypeIds.begin()->first) + "'");
+ // Verify that we have ValueInfo for all function definitions, which are
+ // assumed to be available by downstream consumers.
+ if (M) {
+ for (const Function &F : *M) {
+ if (F.isDeclaration())
+ continue;
+ GlobalValue::GUID GUID = F.getGUIDOrFallback();
+ ValueInfo VI = Index->getValueInfo(GUID);
+ if (!VI || VI.getSummaryList().empty())
+ return error(SMLoc(), "expected function definition " + F.getName() +
+ " to have an associated value info.");
+ }
+ }
+
return false;
}
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..051a21ddd62ec
--- /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: 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