gnu.cfg: Add support for __glibc_likely() and __glibc_unlikely() (#2267)

Reference:
https://sourceware.org/glibc/wiki/Style_and_Conventions#Branch_Prediction
This commit is contained in:
Sebastian 2019-10-14 12:16:28 +02:00 committed by GitHub
parent 4e49b14721
commit 0527b80174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -48,6 +48,8 @@
<define name="__builtin_signbit(value)" value="signbit(value)"/>
<define name="__extension__" value=""/>
<define name="__typeof__(T)" value="typeof(T)"/>
<define name="__glibc_unlikely(x)" value="(x)"/>
<define name="__glibc_likely(x)" value="(x)"/>
<!-- void *__builtin_alloca (size_t size) -->
<!-- alloca() is often defined as __builtin_alloca() so the define above does not work always -->
<!-- void *alloca(size_t size); -->

View File

@ -114,6 +114,8 @@ void valid_code(int argInt1, va_list valist_arg, int * parg)
if (__builtin_expect(argInt1, 0)) {}
if (__builtin_expect_with_probability(argInt1 + 1, 2, 0.5)) {}
if (__glibc_unlikely(argInt1)) {}
if (__glibc_likely(parg)) {}
void *ax1 = __builtin_assume_aligned(parg, 16);
printf("%p", ax1);
void *ax2 = __builtin_assume_aligned(parg, 32, 8);