[PATCH] D144889: [C2x] Support <string.h> in freestanding

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 27 10:33:31 PST 2023


aaron.ballman added a comment.

In D144889#4155686 <https://reviews.llvm.org/D144889#4155686>, @efriedma wrote:

> Providing this header doesn't do anything useful without an actual implementation; all of these "__builtin" calls just lower to libc calls in the general case.  How do you plan to provide implementations?

I *thought* that the difference between:
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Builtins.def#L1038
and
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Builtins.def#L559
was that the first one is lowered to a potential library call while the second one is is lowered to a backend implementation that performs the work. (This is why I thought we would not be able to support `memccpy` or `strtok` -- they were missing the `__builtin_` variants.) If the backend is just going to generate a library call that requires an external library when calling a `__builtin_`, then I agree that there's more here that needs to be done. How do we typically handle it for freestanding functions? Do we implement something in compiler-rt as a fallback, or do we emit LLVM IR for the function implementation, etc?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144889/new/

https://reviews.llvm.org/D144889



More information about the cfe-commits mailing list