diff mbox

Section anchors and thread-local storage

Message ID CAGWvny=ZU6Gny8p3aQ+wz5+CP5KNTY87H+OPjTxd2QtVHKy_+Q@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Nov. 25, 2012, 7:02 p.m. UTC
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.

Comments

Jakub Jelinek Nov. 25, 2012, 8:07 p.m. UTC | #1
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
David Edelsohn Nov. 26, 2012, 12:30 a.m. UTC | #2
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
Richard Sandiford Nov. 26, 2012, 8:26 a.m. UTC | #3
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
diff mbox

Patch

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