[PATCH v1] stdlib: Mark `abort` as `cold`
Carlos O'Donell
carlos@redhat.com
Mon Jul 29 13:29:38 GMT 2024
On 7/29/24 3:36 AM, Noah Goldstein 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. */
I think this should just go in. It will take time to fix llvm and future compilers.
Marking it once here is practical.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list