public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
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
Date: Thu, 13 Aug 2020 18:13:37 +0100	[thread overview]
Message-ID: <CAH6eHdQidoq5A5xmDXyj4XmV6Y8goO6Swbxoz4wWOKEMWUwsyQ@mail.gmail.com> (raw)
In-Reply-To: <BYAPR08MB423270DD470245D666E7FC04B6430@BYAPR08MB4232.namprd08.prod.outlook.com>

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
> ```

  parent reply	other threads:[~2020-08-13 17:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 16:47 Aditya K
2020-08-13 16:51 ` Aditya K
2020-08-13 17:00   ` Aditya K
2020-08-13 17:13   ` Jonathan Wakely [this message]
2020-08-13 18:58     ` Aditya K
     [not found] ` <BYAPR08MB42323E136D6F480F8B138633B65F0@BYAPR08MB4232.namprd08.prod.outlook.com>
2020-08-18 14:35   ` [PATCH] " Jonathan Wakely
2020-08-18 14:38     ` Jonathan Wakely
2020-08-24  8:06     ` Richard Biener
2020-08-24  8:09       ` Jan Hubicka
2020-08-24  8:45         ` Jonathan Wakely
2020-08-24  8:55           ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdQidoq5A5xmDXyj4XmV6Y8goO6Swbxoz4wWOKEMWUwsyQ@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hiraditya@msn.com \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).