Skip to content

Commit ee5ae8c

Browse files
kpdevfhahn
authored andcommitted
[OSX][TargetLibraryInfo] Mark memrchr as unavailable on OSX
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 (`memrchr`) 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 `memrchr` is marked as unavailable for all versions. If someone knows versions where it should be available - please let me know. Github issue: llvm#62254 Tests for this feature also cannot be easily added: https://reviews.llvm.org/D134134#3801747 ~~~ Huawei RRI, OS Lab Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D155168 (cherry-picked from a7a6ef3)
1 parent 829efb1 commit ee5ae8c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
203203
TLI.setAvailable(LibFunc_getchar_unlocked);
204204
TLI.setAvailable(LibFunc_putc_unlocked);
205205
TLI.setAvailable(LibFunc_putchar_unlocked);
206+
TLI.setUnavailable(LibFunc_memrchr);
206207

207208
if (T.isMacOSXVersionLT(10, 5)) {
208209
TLI.setUnavailable(LibFunc_memset_pattern4);

0 commit comments

Comments
 (0)