From: Jakub Jelinek <jakub@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: Andrew Pinski <apinski@marvell.com>,
gcc-patches@gcc.gnu.org, jason@redhat.com
Subject: Re: [PATCH] constexprify some tree variables
Date: Thu, 26 Jan 2023 15:51:07 +0100 [thread overview]
Message-ID: <Y9KTW/wKEeECQQWP@tucnak> (raw)
In-Reply-To: <df5b4bed-58d6-17c4-a1b9-6611a4cf4113@idea>
On Thu, Jan 26, 2023 at 09:45:35AM -0500, Patrick Palka via Gcc-patches wrote:
> > -extern const unsigned char tree_code_length[];
> > +
> > +#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
> > +#define END_OF_BASE_TREE_CODES 0,
> > +constexpr unsigned char tree_code_length[] = {
> > +#include "all-tree.def"
> > +};
> > +
> > +#undef DEFTREECODE
> > +#undef END_OF_BASE_TREE_CODES
>
> IIUC defining these globals as non-inline constexpr gives them internal
> linkage, and so each TU contains its own unique copy of these globals.
> This bloats cc1plus by a tiny bit and is technically an ODR violation
> because some inline functions such as tree_class_check also ODR-use
> these variables and so each defn of tree_class_check will refer to a
> "different" tree_code_class. Since inline variables are a C++17
> feature, I guess we could fix this by defining the globals the old way
> before C++17 and as inline constexpr otherwise?
Agreed, just use
__cpp_inline_variables >= 201606L
to select between the old and new ways.
Jakub
next prev parent reply other threads:[~2023-01-26 14:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 18:05 apinski
2022-11-18 20:06 ` Jeff Law
2022-11-19 2:53 ` Andrew Pinski
2022-11-19 16:33 ` Jeff Law
2023-01-26 14:45 ` Patrick Palka
2023-01-26 14:51 ` Jakub Jelinek [this message]
2023-01-26 14:58 ` Jakub Jelinek
2023-01-26 15:59 ` [PATCH] tree: Fix up tree_code_{length,type} Jakub Jelinek
2023-01-26 18:03 ` Patrick Palka
2023-01-27 12:40 ` Patrick Palka
2023-01-27 13:14 ` Richard Biener
2023-01-27 7:42 ` Richard Biener
2023-01-27 8:57 ` Jakub Jelinek
2023-01-27 9:49 ` Richard Biener
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=Y9KTW/wKEeECQQWP@tucnak \
--to=jakub@redhat.com \
--cc=apinski@marvell.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=ppalka@redhat.com \
/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).