Re: [PATCH] Section anchors and thread-local storage
On Tue, Nov 27, 2012 at 3:17 PM, Richard Sandiford wrote: > David Edelsohn 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
Re: [PATCH] Section anchors and thread-local storage
David Edelsohn 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
Re: [PATCH] Section anchors and thread-local storage
On Mon, Nov 26, 2012 at 3:26 AM, Richard Sandiford wrote: > David Edelsohn 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
Re: [PATCH] Section anchors and thread-local storage
David Edelsohn 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
Re: [PATCH] Section anchors and thread-local storage
On Sun, Nov 25, 2012 at 3:07 PM, Jakub Jelinek 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
Re: [PATCH] Section anchors and thread-local storage
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
[PATCH] Section anchors and thread-local storage
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)))