[PATCH v1] stdlib: Mark `abort` as `cold`
Cristian Rodríguez
cristian@rodriguez.im
Mon Jul 29 15:10:05 GMT 2024
On Mon, Jul 29, 2024 at 3:36 AM Noah Goldstein <goldstein.w.n@gmail.com>
wrote:
> This helps HotColdSplitting in GCC/LLVM.
>
> Thought about doing `exit` as well since its only called once per
> process, but since its easy to imagine a hot path leading into
> `exit(0)`, its less clear if its profitable.
> ---
> stdlib/stdlib.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
> index 901926e893..17487c6640 100644
> --- a/stdlib/stdlib.h
> +++ b/stdlib/stdlib.h
> @@ -727,7 +727,7 @@ extern void *aligned_alloc (size_t __alignment, size_t
> __size)
> #endif
>
> /* Abort execution and generate a core-dump. */
> -extern void abort (void) __THROW __attribute__ ((__noreturn__));
> +extern void abort (void) __THROW __attribute__ ((__noreturn__)) __COLD;
>
>
> /* Register a function to be called when `exit' is called. */
> --
> 2.34.1
>
> GCC already uses cold on __builtin_abort so this patch is correct for the
cases where builtins are not used.
Same applies IMHO to strerror, strerror_r, strerror_l..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20240729/8c1fe471/attachment.htm>
More information about the Libc-alpha
mailing list