Add cold attribute to one time construction APIs
Aditya K
hiraditya@msn.com
Thu Aug 13 18:58:54 GMT 2020
sure.
--
From: Jonathan Wakely <jwakely.gcc@gmail.com>
Sent: Thursday, August 13, 2020 11:13 AM
To: Aditya K <hiraditya@msn.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>; gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: Add cold attribute to one time construction APIs
Please CC the libstdc++ list on all libstdc++ patches.
On Thu, 13 Aug 2020 at 17:51, Aditya K <hiraditya@msn.com> wrote:
>
> Revised patch with _GLIBCXX_COLD added at the end.
>
> ```
> commit 3dc9f9a8461b1c88e991ceb517e5fdd81f268d1e
> Author: Aditya Kumar <1894981+hiraditya@users.noreply.github.com>
> Date: Thu Aug 13 09:41:34 2020 -0700
>
> Add cold attribute to one time construction APIs
>
> __cxa_guard_acquire is used for only one purpose,
> namely guarding local static variable initialization,
> and since that purpose is definitionally cold, it should be attributed as cold.
> Similarly for __cxa_guard_release and __cxa_guard_abort
>
> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> index b1fad59d4..f6f954eef 100644
> --- a/libstdc++-v3/include/bits/c++config
> +++ b/libstdc++-v3/include/bits/c++config
> @@ -35,20 +35,21 @@
>
> // The datestamp of the C++ library in compressed ISO date format.
> #define __GLIBCXX__
>
> // Macros for various attributes.
> // _GLIBCXX_PURE
> // _GLIBCXX_CONST
> // _GLIBCXX_NORETURN
> // _GLIBCXX_NOTHROW
> // _GLIBCXX_VISIBILITY
> +// _GLIBCXX_COLD
> #ifndef _GLIBCXX_PURE
> # define _GLIBCXX_PURE __attribute__ ((__pure__))
> #endif
>
> #ifndef _GLIBCXX_CONST
> # define _GLIBCXX_CONST __attribute__ ((__const__))
> #endif
>
> #ifndef _GLIBCXX_NORETURN
> # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
> @@ -67,20 +68,24 @@
> #define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
>
> #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY
> # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V)))
> #else
> // If this is not supplied by the OS-specific or CPU-specific
> // headers included below, it will be defined to an empty default.
> # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V)
> #endif
>
> +#ifndef _GLIBCXX_COLD
> +# define _GLIBCXX_COLD __attribute__ ((cold))
> +#endif
> +
> // Macros for deprecated attributes.
> // _GLIBCXX_USE_DEPRECATED
> // _GLIBCXX_DEPRECATED
> // _GLIBCXX17_DEPRECATED
> // _GLIBCXX20_DEPRECATED( string-literal )
> #ifndef _GLIBCXX_USE_DEPRECATED
> # define _GLIBCXX_USE_DEPRECATED 1
> #endif
>
> #if defined(__DEPRECATED) && (__cplusplus >= 201103L)
> diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h
> index 000713ecd..24c1366e2 100644
> --- a/libstdc++-v3/libsupc++/cxxabi.h
> +++ b/libstdc++-v3/libsupc++/cxxabi.h
> @@ -108,27 +108,27 @@ namespace __cxxabiv1
> __cxa_vec_delete2(void* __array_address, size_t __element_size,
> size_t __padding_size, __cxa_cdtor_type __destructor,
> void (*__dealloc) (void*));
>
> void
> __cxa_vec_delete3(void* __array_address, size_t __element_size,
> size_t __padding_size, __cxa_cdtor_type __destructor,
> void (*__dealloc) (void*, size_t));
>
> int
> - __cxa_guard_acquire(__guard*);
> + __cxa_guard_acquire(__guard*) _GLIBCXX_COLD;
>
> void
> - __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW;
> + __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW _GLIBCXX_COLD;
>
> void
> - __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW;
> + __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW _GLIBCXX_COLD;
>
> // DSO destruction.
> int
> __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
>
> void
> __cxa_finalize(void*);
>
> // TLS destruction.
> int
> ```
>
> From: Aditya K
> Sent: Thursday, August 13, 2020 10:47 AM
> To: Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org>; jwakely.gcc@gmail.com <jwakely.gcc@gmail.com>
> Subject: Add cold attribute to one time construction APIs
>
> This would help compiler optimize local static objects.
>
> ```
> commit e2f299679ddf56a6d6d71ea9d589cd76b2ca107b
> Author: Aditya Kumar <1894981+hiraditya@users.noreply.github.com>
> Date: Thu Aug 13 09:41:34 2020 -0700
>
> Add cold attribute to one time construction APIs
>
> __cxa_guard_acquire is used for only one purpose,
> namely guarding local static variable initialization,
> and since that purpose is definitionally cold, it should be attributed as cold.
> Similarly for __cxa_guard_release and __cxa_guard_abort
>
> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
> index b1fad59d4..359e955a7 100644
> --- a/libstdc++-v3/include/bits/c++config
> +++ b/libstdc++-v3/include/bits/c++config
> @@ -39,20 +39,24 @@
> // Macros for various attributes.
> // _GLIBCXX_PURE
> // _GLIBCXX_CONST
> // _GLIBCXX_NORETURN
> // _GLIBCXX_NOTHROW
> // _GLIBCXX_VISIBILITY
> #ifndef _GLIBCXX_PURE
> # define _GLIBCXX_PURE __attribute__ ((__pure__))
> #endif
>
> +#ifndef _GLIBCXX_COLD
> +# define _GLIBCXX_COLD __attribute__ ((cold))
> +#endif
> +
> #ifndef _GLIBCXX_CONST
> # define _GLIBCXX_CONST __attribute__ ((__const__))
> #endif
>
> #ifndef _GLIBCXX_NORETURN
> # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__))
> #endif
>
> // See below for C++
> #ifndef _GLIBCXX_NOTHROW
> diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h
> index 000713ecd..24c1366e2 100644
> --- a/libstdc++-v3/libsupc++/cxxabi.h
> +++ b/libstdc++-v3/libsupc++/cxxabi.h
> @@ -108,27 +108,27 @@ namespace __cxxabiv1
> __cxa_vec_delete2(void* __array_address, size_t __element_size,
> size_t __padding_size, __cxa_cdtor_type __destructor,
> void (*__dealloc) (void*));
>
> void
> __cxa_vec_delete3(void* __array_address, size_t __element_size,
> size_t __padding_size, __cxa_cdtor_type __destructor,
> void (*__dealloc) (void*, size_t));
>
> int
> - __cxa_guard_acquire(__guard*);
> + __cxa_guard_acquire(__guard*) _GLIBCXX_COLD;
>
> void
> - __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW;
> + __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW _GLIBCXX_COLD;
>
> void
> - __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW;
> + __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW _GLIBCXX_COLD;
>
> // DSO destruction.
> int
> __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
>
> void
> __cxa_finalize(void*);
>
> // TLS destruction.
> int
> ```
More information about the Gcc-patches
mailing list