diff options
| author | Petr Hosek <phosek@chromium.org> | 2019-04-29 00:46:23 +0000 |
|---|---|---|
| committer | Petr Hosek <phosek@chromium.org> | 2019-04-29 00:46:23 +0000 |
| commit | 84da0e1bb75f8666cf222d2f600f37bebb9ea389 (patch) | |
| tree | 48658b33c89c8d8586379bf95d0f5b402ef42d27 /compiler-rt/lib/builtins/int_lib.h | |
| parent | aec5dcc4579fda255c308b002cebe24b104b8df2 (diff) | |
| download | bcm5719-llvm-84da0e1bb75f8666cf222d2f600f37bebb9ea389.tar.gz bcm5719-llvm-84da0e1bb75f8666cf222d2f600f37bebb9ea389.zip | |
[builtins] Use aliases for function redirects
Symbol aliases are supported by all platforms that compiler-rt builtins
target, and we can use these instead of function redirects to avoid the
extra indirection.
This is part of the cleanup proposed in "[RFC] compiler-rt builtins
cleanup and refactoring".
Differential Revision: https://reviews.llvm.org/D60931
llvm-svn: 359413
Diffstat (limited to 'compiler-rt/lib/builtins/int_lib.h')
| -rw-r--r-- | compiler-rt/lib/builtins/int_lib.h | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/compiler-rt/lib/builtins/int_lib.h b/compiler-rt/lib/builtins/int_lib.h index 15d825588a9..4eb0565fc36 100644 --- a/compiler-rt/lib/builtins/int_lib.h +++ b/compiler-rt/lib/builtins/int_lib.h @@ -18,17 +18,6 @@ // Assumption: Right shift of signed negative is arithmetic shift. // Assumption: Endianness is little or big (not mixed). -#if defined(__ELF__) -#define FNALIAS(alias_name, original_name) \ - void alias_name() __attribute__((__alias__(#original_name))) -#define COMPILER_RT_ALIAS(aliasee) __attribute__((__alias__(#aliasee))) -#else -#define FNALIAS(alias, name) \ - _Pragma("GCC error(\"alias unsupported on this file format\")") -#define COMPILER_RT_ALIAS(aliasee) \ - _Pragma("GCC error(\"alias unsupported on this file format\")") -#endif - // ABI macro definitions #if __ARM_EABI__ @@ -55,6 +44,24 @@ #define UNUSED __attribute__((unused)) #endif +#define STR(a) #a +#define XSTR(a) STR(a) +#define SYMBOL_NAME(name) XSTR(__USER_LABEL_PREFIX__) #name + +#if defined(__ELF__) || defined(__MINGW32__) || defined(__wasm__) +#define COMPILER_RT_ALIAS(name, aliasname) \ + COMPILER_RT_ABI __typeof(name) aliasname __attribute__((__alias__(#name))); +#elif defines(__MACH__) +#define COMPILER_RT_ALIAS(name, aliasname) \ + __asm__(".globl " SYMBOL_NAME(aliasname)); \ + __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)) \ + COMPILER_RT_ABI __typeof(name) aliasname; +#elif defined(_WIN32) +#define COMPILER_RT_ALIAS(name, aliasname) +#else +#error Unsupported target +#endif + #if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE)) // // Kernel and boot environment can't use normal headers, |

