[PATCH] malloc: remove __builtin_expect
Florian Weimer
fweimer@redhat.com
Tue Jan 26 21:45:00 GMT 2016
On 01/26/2016 10:34 PM, Steven Munroe wrote:
>> Based on what I saw, glibc uses __builtin_expect and the macros derived
>> from it in two conflicting ways: to express that one alternative is more
>> likely that the other, and to state that some alternative is impossible
>> in practice (for a well-behaved program in particular).
>>
>> GCC's current interpretation leans towards the latter, at least on
>> x86_64. I think GCC even puts unlikely code into separate text sections
>> in some cases. Most of our __builtin_expect uses seem to be of the
>> former nature: things that can and do happen during normal operation,
>> like an unusual character in a character set conversion, or a
>> locale-related environment variable which is set.
>>
> I am also concerned the GCC has some serious bugs in its block frequency
> handling. For example:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67755
Hmm. So maybe what I saw looking at disassembly was a consequence of
this bug, and not intended GCC behavior.
Florian
More information about the Libc-alpha
mailing list