This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] malloc: remove __builtin_expect
- From: Florian Weimer <fweimer at redhat dot com>
- To: munroesj at linux dot vnet dot ibm dot com
- Cc: Yury Gribov <y dot gribov at samsung dot com>, Joern Engel <joern at purestorage dot com>, "GNU C. Library" <libc-alpha at sourceware dot org>, Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>, Joern Engel <joern at purestorage dot org>
- Date: Tue, 26 Jan 2016 22:44:57 +0100
- Subject: Re: [PATCH] malloc: remove __builtin_expect
- Authentication-results: sourceware.org; auth=none
- References: <1453767942-19369-1-git-send-email-joern at purestorage dot com> <1453767942-19369-21-git-send-email-joern at purestorage dot com> <56A726C1 dot 6070206 at samsung dot com> <1453840993 dot 18407 dot 2 dot camel at oc7878010663> <56A7E028 dot 6050204 at redhat dot com> <1453844092 dot 18407 dot 9 dot camel at oc7878010663>
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