[llvm] Fix FreeBSD LTO build (PR #215056)
Theo Paris via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 8 22:13:31 PDT 2026
https://github.com/theoparis created https://github.com/llvm/llvm-project/pull/215056
Previously, both clang 21 and 24 would crash/abort when either `-flto=thin` or `-flto=full` was passed to the FreeBSD kernel build flags. This fixes two separate issues, one at link time and one when compiling `pmap.c`.
Assisted-by: Claude Sonnet 5
>From 4a52ed158417c4e6d1d819d44031cebfa8e1c0ff Mon Sep 17 00:00:00 2001
From: Theo Paris <theo at theoparis.com>
Date: Sat, 8 Aug 2026 22:08:01 -0700
Subject: [PATCH] Fix FreeBSD LTO build
---
llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 +++-
llvm/lib/IR/Globals.cpp | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index ac61ede6395af..dc24104f56107 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -7603,10 +7603,12 @@ Error ModuleSummaryIndexBitcodeReader::parseModule() {
// v1 GLOBALVAR: [pointer type, isconst, initid, linkage, ...]
// v1 FUNCTION: [type, callingconv, isproto, linkage, ...]
// v1 ALIAS: [alias type, addrspace, aliasee val#, linkage, ...]
+ // v1 IFUNC: [ifunc type, addrspace, resolver val#,linkage, ...]
// v2: [strtab offset, strtab size, v1]
case bitc::MODULE_CODE_GLOBALVAR:
case bitc::MODULE_CODE_FUNCTION:
- case bitc::MODULE_CODE_ALIAS: {
+ case bitc::MODULE_CODE_ALIAS:
+ case bitc::MODULE_CODE_IFUNC: {
StringRef Name;
ArrayRef<uint64_t> GVRecord;
std::tie(Name, GVRecord) = readNameFromStrtab(Record);
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 3428f662e9120..e11a1072ab012 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -126,7 +126,10 @@ std::optional<GlobalValue::GUID> GlobalValue::getGUIDIfAssigned() const {
// current properties.
// TODO: Maybe we should use a more robust check for intrinsics than just
// matching on the name?
- if (isDeclaration() || isa<GlobalAlias>(this) ||
+ // GlobalAlias and GlobalIFunc are not GlobalObjects and so cannot carry
+ // GUID metadata (see getGUIDMetadata()); always compute their GUID
+ // on the fly.
+ if (isDeclaration() || isa<GlobalAlias>(this) || isa<GlobalIFunc>(this) ||
getName().starts_with("llvm.")) {
return GlobalValue::getGUIDAssumingExternalLinkage(getGlobalIdentifier());
}
More information about the llvm-commits
mailing list