public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Backport fix for PR c++/85400
@ 2019-05-22  7:43 Eric Botcazou
  2019-05-22  9:11 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Botcazou @ 2019-05-22  7:43 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

Jakub asked me to backport the fix for PR c++/85400 initially intended for 
SPARC/Solaris but which also helps on x86-64/Linux apparently.

Tested on the latter platform, applied on the 8 branch.


2019-05-22  Eric Botcazou  <ebotcazou@adacore.com>

c-family/
	Backport from mainline
	2018-05-10  Eric Botcazou  <ebotcazou@adacore.com>

	PR c++/85400
	* c-attribs.c (handle_visibility_attribute): Do not set no_add_attrs.


2019-05-22  Eric Botcazou  <ebotcazou@adacore.com>

cp/
	Backport from mainline
	2018-05-10  Eric Botcazou  <ebotcazou@adacore.com>

	PR c++/85400
	* decl2.c (adjust_var_decl_tls_model): New static function.
	(comdat_linkage): Call it on a variable.
	(maybe_make_one_only): Likewise.


2019-05-22  Eric Botcazou  <ebotcazou@adacore.com>

	* g++.dg/tls/pr85400.C: New test.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1792 bytes --]

Index: c-family/c-attribs.c
===================================================================
--- c-family/c-attribs.c	(revision 270883)
+++ c-family/c-attribs.c	(working copy)
@@ -2310,14 +2310,13 @@ handle_visibility_attribute (tree *node,
 
 static tree
 handle_tls_model_attribute (tree *node, tree name, tree args,
-			    int ARG_UNUSED (flags), bool *no_add_attrs)
+			    int ARG_UNUSED (flags),
+			    bool *ARG_UNUSED (no_add_attrs))
 {
   tree id;
   tree decl = *node;
   enum tls_model kind;
 
-  *no_add_attrs = true;
-
   if (!VAR_P (decl) || !DECL_THREAD_LOCAL_P (decl))
     {
       warning (OPT_Wattributes, "%qE attribute ignored", name);
Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 270883)
+++ cp/decl2.c	(working copy)
@@ -1838,6 +1838,17 @@ mark_vtable_entries (tree decl)
     }
 }
 
+/* Adjust the TLS model on variable DECL if need be, typically after
+   the linkage of DECL has been modified.  */
+
+static void
+adjust_var_decl_tls_model (tree decl)
+{
+  if (CP_DECL_THREAD_LOCAL_P (decl)
+      && !lookup_attribute ("tls_model", DECL_ATTRIBUTES (decl)))
+    set_decl_tls_model (decl, decl_default_tls_model (decl));
+}
+
 /* Set DECL up to have the closest approximation of "initialized common"
    linkage available.  */
 
@@ -1888,6 +1899,9 @@ comdat_linkage (tree decl)
 
   if (TREE_PUBLIC (decl))
     DECL_COMDAT (decl) = 1;
+
+  if (VAR_P (decl))
+    adjust_var_decl_tls_model (decl);
 }
 
 /* For win32 we also want to put explicit instantiations in
@@ -1926,6 +1940,8 @@ maybe_make_one_only (tree decl)
 	  /* Mark it needed so we don't forget to emit it.  */
           node->forced_by_abi = true;
 	  TREE_USED (decl) = 1;
+
+	  adjust_var_decl_tls_model (decl);
 	}
     }
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Backport fix for PR c++/85400
  2019-05-22  7:43 Backport fix for PR c++/85400 Eric Botcazou
@ 2019-05-22  9:11 ` Richard Biener
  2019-05-22 22:32   ` Eric Botcazou
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2019-05-22  9:11 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches

On Wed, May 22, 2019 at 9:43 AM Eric Botcazou <ebotcazou@adacore.com> wrote:
>
> Jakub asked me to backport the fix for PR c++/85400 initially intended for
> SPARC/Solaris but which also helps on x86-64/Linux apparently.
>
> Tested on the latter platform, applied on the 8 branch.

Probably also required for GCC 7 then?

Richard.

>
> 2019-05-22  Eric Botcazou  <ebotcazou@adacore.com>
>
> c-family/
>         Backport from mainline
>         2018-05-10  Eric Botcazou  <ebotcazou@adacore.com>
>
>         PR c++/85400
>         * c-attribs.c (handle_visibility_attribute): Do not set no_add_attrs.
>
>
> 2019-05-22  Eric Botcazou  <ebotcazou@adacore.com>
>
> cp/
>         Backport from mainline
>         2018-05-10  Eric Botcazou  <ebotcazou@adacore.com>
>
>         PR c++/85400
>         * decl2.c (adjust_var_decl_tls_model): New static function.
>         (comdat_linkage): Call it on a variable.
>         (maybe_make_one_only): Likewise.
>
>
> 2019-05-22  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * g++.dg/tls/pr85400.C: New test.
>
> --
> Eric Botcazou

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Backport fix for PR c++/85400
  2019-05-22  9:11 ` Richard Biener
@ 2019-05-22 22:32   ` Eric Botcazou
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Botcazou @ 2019-05-22 22:32 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

> Probably also required for GCC 7 then?

The problem is (probably) present there too, but that's not my call.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-22 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22  7:43 Backport fix for PR c++/85400 Eric Botcazou
2019-05-22  9:11 ` Richard Biener
2019-05-22 22:32   ` Eric Botcazou

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).