public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Section anchors and thread-local storage
@ 2012-11-25 19:02 David Edelsohn
  2012-11-25 20:07 ` Jakub Jelinek
  2012-11-26  8:26 ` Richard Sandiford
  0 siblings, 2 replies; 7+ messages in thread
From: David Edelsohn @ 2012-11-25 19:02 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: GCC Patches

I have been working to enable native thread-local storage on AIX. One
problem I encountered is the AIX assembler has difficulty with the
anchor symbol for TLS CSECTs.  While the section anchors machinery
uses a separate pool for TLS entries, should section anchor blocks be
used for TLS symbols at all?

powerpc-linux uses GOT annotations directly and never places TLS
symbols in the TOC at all. Section anchors seem to be avoided by TLS
code already.  The appended patch rejects TLS symbols for object
blocks in general. I could add a target hook, but I wanted to propose
this policy in general before pursing a target-specific hook.

Thanks, David

        * varasm.c: (use_blocks_for_decl_p): Do not place thread-local symbols
        refs in object blocks.

Index: varasm.c
===================================================================
--- varasm.c    (revision 193785)
+++ varasm.c    (working copy)
@@ -1108,6 +1108,10 @@
   if (DECL_INITIAL (decl) == decl)
     return false;

+  /* Do not place thread-local symbols refs in the object blocks.  */
+  if (DECL_TLS_MODEL (decl) != 0)
+    return false;
+
   /* If this decl is an alias, then we don't want to emit a
      definition.  */
   if (lookup_attribute ("alias", DECL_ATTRIBUTES (decl)))

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

* Re: [PATCH] Section anchors and thread-local storage
  2012-11-25 19:02 [PATCH] Section anchors and thread-local storage David Edelsohn
@ 2012-11-25 20:07 ` Jakub Jelinek
  2012-11-26  0:30   ` David Edelsohn
  2012-11-26  8:26 ` Richard Sandiford
  1 sibling, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2012-11-25 20:07 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Richard Sandiford, GCC Patches

On Sun, Nov 25, 2012 at 02:02:05PM -0500, David Edelsohn wrote:
> I have been working to enable native thread-local storage on AIX. One
> problem I encountered is the AIX assembler has difficulty with the
> anchor symbol for TLS CSECTs.  While the section anchors machinery
> uses a separate pool for TLS entries, should section anchor blocks be
> used for TLS symbols at all?
> 
> powerpc-linux uses GOT annotations directly and never places TLS
> symbols in the TOC at all. Section anchors seem to be avoided by TLS
> code already.  The appended patch rejects TLS symbols for object
> blocks in general. I could add a target hook, but I wanted to propose
> this policy in general before pursing a target-specific hook.
> 
> Thanks, David
> 
>         * varasm.c: (use_blocks_for_decl_p): Do not place thread-local symbols
>         refs in object blocks.
> 
> Index: varasm.c
> ===================================================================
> --- varasm.c    (revision 193785)
> +++ varasm.c    (working copy)
> @@ -1108,6 +1108,10 @@
>    if (DECL_INITIAL (decl) == decl)
>      return false;
> 
> +  /* Do not place thread-local symbols refs in the object blocks.  */
> +  if (DECL_TLS_MODEL (decl) != 0)
> +    return false;

Do you want to handle TLS_MODEL_EMULATED that way?  If not, the test
should be DECL_THREAD_LOCAL_P (decl) (I believe you want that),
if yes, perhaps DECL_TLS_MODEL (decl) != TLS_MODEL_NONE.

	Jakub

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

* Re: [PATCH] Section anchors and thread-local storage
  2012-11-25 20:07 ` Jakub Jelinek
@ 2012-11-26  0:30   ` David Edelsohn
  0 siblings, 0 replies; 7+ messages in thread
From: David Edelsohn @ 2012-11-26  0:30 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Richard Sandiford, GCC Patches

On Sun, Nov 25, 2012 at 3:07 PM, Jakub Jelinek <jakub@redhat.com> wrote:

> Do you want to handle TLS_MODEL_EMULATED that way?  If not, the test
> should be DECL_THREAD_LOCAL_P (decl) (I believe you want that),
> if yes, perhaps DECL_TLS_MODEL (decl) != TLS_MODEL_NONE.

Thanks for pointing this out.  I should have used DECL_THREAD_LOCAL_P .

The question and proposed patch remain open.

Thanks, David

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

* Re: [PATCH] Section anchors and thread-local storage
  2012-11-25 19:02 [PATCH] Section anchors and thread-local storage David Edelsohn
  2012-11-25 20:07 ` Jakub Jelinek
@ 2012-11-26  8:26 ` Richard Sandiford
  2012-11-26 16:53   ` David Edelsohn
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Sandiford @ 2012-11-26  8:26 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GCC Patches

David Edelsohn <dje.gcc@gmail.com> writes:
> I have been working to enable native thread-local storage on AIX. One
> problem I encountered is the AIX assembler has difficulty with the
> anchor symbol for TLS CSECTs.  While the section anchors machinery
> uses a separate pool for TLS entries, should section anchor blocks be
> used for TLS symbols at all?
>
> powerpc-linux uses GOT annotations directly and never places TLS
> symbols in the TOC at all. Section anchors seem to be avoided by TLS
> code already.  The appended patch rejects TLS symbols for object
> blocks in general. I could add a target hook, but I wanted to propose
> this policy in general before pursing a target-specific hook.

Yeah, TLS anchors "work" on mips64-linux-gnu, although admittedly
section anchors aren't yet enabled by default there, so perhaps not
many people have tried it.

A use_blocks_for_decl_p hook sounds good, and fits nicely with
targetm.use_blocks_for_constant_p.

Thanks,
Richard

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

* Re: [PATCH] Section anchors and thread-local storage
  2012-11-26  8:26 ` Richard Sandiford
@ 2012-11-26 16:53   ` David Edelsohn
  2012-11-27 20:18     ` Richard Sandiford
  0 siblings, 1 reply; 7+ messages in thread
From: David Edelsohn @ 2012-11-26 16:53 UTC (permalink / raw)
  To: GCC Patches, rdsandiford

On Mon, Nov 26, 2012 at 3:26 AM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> David Edelsohn <dje.gcc@gmail.com> writes:
>> I have been working to enable native thread-local storage on AIX. One
>> problem I encountered is the AIX assembler has difficulty with the
>> anchor symbol for TLS CSECTs.  While the section anchors machinery
>> uses a separate pool for TLS entries, should section anchor blocks be
>> used for TLS symbols at all?
>>
>> powerpc-linux uses GOT annotations directly and never places TLS
>> symbols in the TOC at all. Section anchors seem to be avoided by TLS
>> code already.  The appended patch rejects TLS symbols for object
>> blocks in general. I could add a target hook, but I wanted to propose
>> this policy in general before pursing a target-specific hook.
>
> Yeah, TLS anchors "work" on mips64-linux-gnu, although admittedly
> section anchors aren't yet enabled by default there, so perhaps not
> many people have tried it.

I know that it *CAN* work. Part of my question was whether
thread-local symbols *SHOULD* be placed in section anchor blocks,
whether or not they can be placed there on some systems.

> A use_blocks_for_decl_p hook sounds good, and fits nicely with
> targetm.use_blocks_for_constant_p.

Below is the implementation as a new target hook.

Thanks, David

        * target.def (use_blocks_for_decl_p): New hook.
        * varasm.c (use_blocks_for_decl_p): Apply hook as final condition.

Index: target.def
===================================================================
--- target.def  (revision 193798)
+++ target.def  (working copy)
@@ -1495,6 +1495,13 @@
  bool, (enum machine_mode mode, const_rtx x),
  hook_bool_mode_const_rtx_false)

+/* True if the given decl can be put into an object_block.  */
+DEFHOOK
+(use_blocks_for_decl_p,
+ "",
+ bool, (const_tree decl),
+ hook_bool_const_tree_true)
+
 /* The minimum and maximum byte offsets for anchored addresses.  */
 DEFHOOKPOD
 (min_anchor_offset,
Index: varasm.c
===================================================================
--- varasm.c    (revision 193798)
+++ varasm.c    (working copy)
@@ -1113,7 +1113,7 @@
   if (lookup_attribute ("alias", DECL_ATTRIBUTES (decl)))
     return false;

-  return true;
+  return targetm.use_blocks_for_decl_p (decl);
 }

 /* Create the DECL_RTL for a VAR_DECL or FUNCTION_DECL.  DECL should

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

* Re: [PATCH] Section anchors and thread-local storage
  2012-11-26 16:53   ` David Edelsohn
@ 2012-11-27 20:18     ` Richard Sandiford
  2012-11-27 20:45       ` David Edelsohn
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Sandiford @ 2012-11-27 20:18 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GCC Patches

David Edelsohn <dje.gcc@gmail.com> writes:
> Below is the implementation as a new target hook.

Looks good to me.  The documentation string needs filling in though,
with a hook placeholder in tm.texi.in.

Richard

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

* Re: [PATCH] Section anchors and thread-local storage
  2012-11-27 20:18     ` Richard Sandiford
@ 2012-11-27 20:45       ` David Edelsohn
  0 siblings, 0 replies; 7+ messages in thread
From: David Edelsohn @ 2012-11-27 20:45 UTC (permalink / raw)
  To: GCC Patches, rdsandiford

On Tue, Nov 27, 2012 at 3:17 PM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> David Edelsohn <dje.gcc@gmail.com> writes:
>> Below is the implementation as a new target hook.
>
> Looks good to me.  The documentation string needs filling in though,
> with a hook placeholder in tm.texi.in.

Yes.

Thanks, David

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

end of thread, other threads:[~2012-11-27 20:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-25 19:02 [PATCH] Section anchors and thread-local storage David Edelsohn
2012-11-25 20:07 ` Jakub Jelinek
2012-11-26  0:30   ` David Edelsohn
2012-11-26  8:26 ` Richard Sandiford
2012-11-26 16:53   ` David Edelsohn
2012-11-27 20:18     ` Richard Sandiford
2012-11-27 20:45       ` David Edelsohn

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