assert: Mark `__assert_fail` as `cold`
Sam James
sam@gentoo.org
Fri Jul 26 10:17:23 GMT 2024
Noah Goldstein <goldstein.w.n@gmail.com> writes:
> This helps compilers split the codegen for setting up the arguments
> (`__expression`, `__filename`, etc...) from the potentially hot cold
> where the `assert` is to a presumably cold region on the assertion
> failure path.
It looks good to me too, but I'm a little surprised this didn't come up
before.
I dug a bit more and found
https://inbox.sourceware.org/libc-alpha/BYAPR08MB4232749003F118FA852BA0E5B6730@BYAPR08MB4232.namprd08.prod.outlook.com/,
but nothing else.
Reviewed-by: Sam James <sam@gentoo.org>
> ---
> assert/assert.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/assert/assert.h b/assert/assert.h
> index 266a41df06..3261eb4202 100644
> --- a/assert/assert.h
> +++ b/assert/assert.h
> @@ -71,13 +71,13 @@ extern void __assert_fail (const char *__assertion, const char *__file,
> /* Likewise, but prints the error text for ERRNUM. */
> extern void __assert_perror_fail (int __errnum, const char *__file,
> unsigned int __line, const char *__function)
> - __THROW __attribute__ ((__noreturn__));
> + __THROW __attribute__ ((__noreturn__)) __COLD;
>
>
> /* The following is not at all used here but needed for standard
> compliance. */
> extern void __assert (const char *__assertion, const char *__file, int __line)
> - __THROW __attribute__ ((__noreturn__));
> + __THROW __attribute__ ((__noreturn__)) __COLD;
>
>
> __END_DECLS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 377 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20240726/74900408/attachment.sig>
More information about the Libc-alpha
mailing list