[PATCH] D155168: [OSX][TargetLibraryInfo] Mark memchr as unavailable on OSX
Pavel Kosov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 13 03:13:02 PDT 2023
kpdev42 created this revision.
kpdev42 added reviewers: nikic, arichardson, msebor, spatel.
kpdev42 added a project: LLVM.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
kpdev42 requested review of this revision.
On Mac OSX (tested version macOS 12.4, sdk 12.1) llvm can replace call to `strrchr()` with call to `memrchr()` when string length is known at compile time. This results in link error, because `memrchr` is not present in `libSystem`. It is needed to disable this optimization in `TargetLibraryInfo` for affected OSX versions.
This non-standard function (`memchr`) is not present on (at least) several versions of MacOS https://www.gnu.org/software/gnulib/manual/html_node/memrchr.html , so, in this patch `memchr` is marked as unavailable for all versions. If someone knows versions where it should be available - please let me know.
Github issue: https://github.com/llvm/llvm-project/issues/62254
Tests for this feature also cannot be easily added: https://reviews.llvm.org/D134134#3801747
~~~
Huawei RRI, OS Lab
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155168
Files:
llvm/lib/Analysis/TargetLibraryInfo.cpp
Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -203,6 +203,7 @@
TLI.setAvailable(LibFunc_getchar_unlocked);
TLI.setAvailable(LibFunc_putc_unlocked);
TLI.setAvailable(LibFunc_putchar_unlocked);
+ TLI.setUnavailable(LibFunc_memchr);
if (T.isMacOSXVersionLT(10, 5)) {
TLI.setUnavailable(LibFunc_memset_pattern4);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155168.539909.patch
Type: text/x-patch
Size: 501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230713/08a58b7f/attachment.bin>
More information about the llvm-commits
mailing list