2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 01:59:26 +00:00
bind/cocci/isc_buffer_allocate_never_fail.spatch
Ondřej Surý e603983ec9 Stop providing branch prediction information
The __builtin_expect() can be used to provide the compiler with branch
prediction information.  The Gcc manual says[1] on the subject:

    In general, you should prefer to use actual profile feedback for
    this (-fprofile-arcs), as programmers are notoriously bad at
    predicting how their programs actually perform.

Stop using __builtin_expect() and ISC_LIKELY() and ISC_UNLIKELY() macros
to provide the branch prediction information as the performance testing
shows that named performs better when the __builtin_expect() is not
being used.

1. https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fexpect
2021-10-14 10:33:24 +02:00

76 lines
709 B
Plaintext

@@
statement S;
expression V;
@@
- V =
isc_buffer_allocate(...);
- if (V != ISC_R_SUCCESS) S
@@
statement S1, S2;
expression V;
@@
- V =
isc_buffer_allocate(...);
- if (V == ISC_R_SUCCESS)
S1
- else S2
@@
expression V;
@@
- V =
isc_buffer_allocate(...);
- check_result(V, ...);
@@
@@
- CHECK(
isc_buffer_allocate(...)
- )
;
@@
@@
- DO(...,
isc_buffer_allocate(...)
- )
;
@@
@@
- RETERR(
isc_buffer_allocate(...)
- )
;
@@
expression V;
@@
- V =
isc_buffer_allocate(...);
- assert_int_equal(V, ISC_R_SUCCESS);
@@
expression V;
@@
- V =
isc_buffer_allocate(...);
- CHECK(..., V);
@@
expression V;
@@
- V =
isc_buffer_allocate(...);
- RUNTIME_CHECK(V == ISC_R_SUCCESS);