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: 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
Isn't this supposed to be memrchr?