[libc-commits] [libc] [libc] Move from alias(X) to asm(X) for aliasing (PR #89333)

via libc-commits libc-commits at lists.llvm.org
Fri Apr 19 02:35:05 PDT 2024


================
@@ -25,7 +25,7 @@
 #define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist)                           \
   LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name)                       \
       __##name##_impl__ __asm__(#name);                                        \
-  decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]];                   \
----------------
lntue wrote:

The semantic of these 2 are different.  In the old one,
```
decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]];
```
will give you a public C++ function `LIBC_NAMESPACE::name` (b/c we used this macro inside `namespace LIBC_NAMESPACE { ... }` which is internally aliased to the public C symbol `#name`.
On the other hand, the second one using `asm` will simply make the public symbol of `LIBC_NAMESPACE::name` as unmangled `#name`.

So this change will make `LIBC_NAMESPACE::name` not available outside of the translation unit.

https://github.com/llvm/llvm-project/pull/89333


More information about the libc-commits mailing list