[llvm] TargetLibraryInfo: Bring FreeBSD function list up to date (PR #144846)
Gleb Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 18 23:42:42 PDT 2025
https://github.com/arrowd updated https://github.com/llvm/llvm-project/pull/144846
>From 2c7ab95be00d59047534d6a6785cbee46fbe949a Mon Sep 17 00:00:00 2001
From: Gleb Popov <6yearold at gmail.com>
Date: Thu, 19 Jun 2025 09:32:06 +0300
Subject: [PATCH 1/2] llvm-tli-checker: Take ifunc symbols into account
FreeBSD libc has a lot of symbols that are ifuncs, which makes TLI checker
believe they are not available.
---
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp b/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
index ca0b424722196..95795b16a6798 100644
--- a/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
+++ b/llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
@@ -168,8 +168,12 @@ void SDKNameMap::maybeInsertSymbol(const SymbolRef &S, const ObjectFile &O) {
uint32_t Flags = unwrapIgnoreError(S.getFlags());
section_iterator Section = unwrapIgnoreError(S.getSection(),
/*Default=*/O.section_end());
- if (Type == SymbolRef::ST_Function && (Flags & SymbolRef::SF_Global) &&
- Section != O.section_end()) {
+ bool IsRegularFunction = Type == SymbolRef::ST_Function &&
+ (Flags & SymbolRef::SF_Global) &&
+ Section != O.section_end();
+ bool IsIFunc =
+ Type == SymbolRef::ST_Other && (Flags & SymbolRef::SF_Indirect);
+ if (IsRegularFunction || IsIFunc) {
StringRef Name = unwrapIgnoreError(S.getName());
insert({ Name, true });
}
>From eaa2a4185a707280637f5fb09b6644be2dbdfc5e Mon Sep 17 00:00:00 2001
From: Gleb Popov <6yearold at gmail.com>
Date: Thu, 19 Jun 2025 09:33:51 +0300
Subject: [PATCH 2/2] TargetLibraryInfo: Bring FreeBSD function list up to date
---
llvm/lib/Analysis/TargetLibraryInfo.cpp | 28 +++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index a3ed093134390..b19ffeabaafad 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -874,6 +874,34 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
TLI.setUnavailable(LibFunc_toascii);
}
+ if (T.isOSFreeBSD()) {
+ TLI.setAvailable(LibFunc_dunder_strtok_r);
+ TLI.setAvailable(LibFunc_memalign);
+ TLI.setAvailable(LibFunc_fputc_unlocked);
+ TLI.setAvailable(LibFunc_fputs_unlocked);
+ TLI.setAvailable(LibFunc_fread_unlocked);
+ TLI.setAvailable(LibFunc_fwrite_unlocked);
+ TLI.setAvailable(LibFunc_getc_unlocked);
+ TLI.setAvailable(LibFunc_getchar_unlocked);
+ TLI.setAvailable(LibFunc_putc_unlocked);
+ TLI.setAvailable(LibFunc_putchar_unlocked);
+
+ TLI.setUnavailable(LibFunc___kmpc_alloc_shared);
+ TLI.setUnavailable(LibFunc___kmpc_free_shared);
+ TLI.setUnavailable(LibFunc_dunder_strndup);
+ TLI.setUnavailable(LibFunc_memccpy_chk);
+ TLI.setUnavailable(LibFunc_strlen_chk);
+ TLI.setUnavailable(LibFunc_fmaximum_num);
+ TLI.setUnavailable(LibFunc_fmaximum_numf);
+ TLI.setUnavailable(LibFunc_fmaximum_numl);
+ TLI.setUnavailable(LibFunc_fminimum_num);
+ TLI.setUnavailable(LibFunc_fminimum_numf);
+ TLI.setUnavailable(LibFunc_fminimum_numl);
+ TLI.setUnavailable(LibFunc_roundeven);
+ TLI.setUnavailable(LibFunc_roundevenf);
+ TLI.setUnavailable(LibFunc_roundevenl);
+ }
+
// As currently implemented in clang, NVPTX code has no standard library to
// speak of. Headers provide a standard-ish library implementation, but many
// of the signatures are wrong -- for example, many libm functions are not
More information about the llvm-commits
mailing list