[PATCH v1] stdlib: Mark `abort` as `cold`
Andrew Pinski
pinskia@gmail.com
Mon Jul 29 07:42:09 GMT 2024
On Mon, Jul 29, 2024 at 12: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.
In fact GCC has predict heuristics explicitly to ignore `exit(0)` but
only for noreturn:
Added at https://gcc.gnu.org/r7-3919-ge25a366f6fbfec .
Thanks,
Andrew Pinski
> ---
> 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
>
More information about the Libc-alpha
mailing list