public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++, v2: Drop TREE_READONLY on vars (possibly) initialized by tls wrapper [PR109164]
Date: Mon, 20 Mar 2023 16:45:25 +0100	[thread overview]
Message-ID: <ZBh/leVAUM3D99gS@tucnak> (raw)
In-Reply-To: <ZBXUQ06ObKinZSSc@tucnak>

On Sat, Mar 18, 2023 at 04:09:55PM +0100, Jakub Jelinek via Gcc-patches wrote:
> On Sat, Mar 18, 2023 at 01:54:58PM +0100, Jakub Jelinek via Gcc-patches wrote:
> > The patch is mostly about DECL_EXTERNAL cases, the others are supposedly
> > handled by the var_definition_p code there (or at least I assumed;
> > testcases certainly test only DECL_EXTERNAL).
> > I guess it could be done in cp_finish_decl, maybe better next to the
> >   /* A reference will be modified here, as it is initialized.  */
> >   if (! DECL_EXTERNAL (decl)
> >       && TREE_READONLY (decl)
> >       && TYPE_REF_P (type))
> >     {
> >       was_readonly = 1;
> >       TREE_READONLY (decl) = 0;
> >     }
> > spot, but we'd need to export the decl2.cc helpers for it,
> > because not all DECL_THREAD_LOCAL_P vars need to be treated that way.
> >   if (VAR_P (decl)
> >       && CP_DECL_THREAD_LOCAL_P (decl)
> >       && var_needs_tls_wrapper (decl)
> >       && (!DECL_EXTERNAL (decl) || flag_extern_tls_init))
> >     TREE_READONLY (decl) = 0;
> > where var_needs_tls_wrapper would need to be exported from decl2.cc.
> > Though, var_needs_tls_wrapper -> var_defined_without_dynamic_init
> > needs
> > DECL_NONTRIVIALLY_INITIALIZED_P/DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P,
> > so perhaps that is accurate only closer to the end of cp_finish_decl?
> 
> Here it is in patch form, tested so far on tls.exp:

And successfully bootstrapped/regtested on x86_64-linux and i686-linux over
the weekend.

> 2023-03-18  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c++/109164
> 	* cp-tree.h (var_needs_tls_wrapper): Declare.
> 	* decl2.cc (var_needs_tls_wrapper): No longer static.
> 	* decl.cc (cp_finish_decl): Clear TREE_READONLY on TLS variables
> 	for which a TLS wrapper will be needed.
> 
> 	* g++.dg/tls/thread_local13.C: New test.
> 	* g++.dg/tls/thread_local13-aux.cc: New file.
> 	* g++.dg/tls/thread_local14.C: New test.
> 	* g++.dg/tls/thread_local14-aux.cc: New file.

	Jakub


  reply	other threads:[~2023-03-20 15:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 17:51 [PATCH] c++: " Jakub Jelinek
2023-03-18 12:39 ` Jason Merrill
2023-03-18 12:54   ` Jakub Jelinek
2023-03-18 15:09     ` [PATCH] c++, v2: " Jakub Jelinek
2023-03-20 15:45       ` Jakub Jelinek [this message]
2023-03-20 19:15       ` Jason Merrill
2023-03-20 19:26         ` Jakub Jelinek
2023-03-20 19:28           ` Jason Merrill

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=ZBh/leVAUM3D99gS@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@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).