From patchwork Mon Nov 26 16:53:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Section anchors and thread-local storage From: David Edelsohn X-Patchwork-Id: 201733 Message-Id: To: GCC Patches , rdsandiford@googlemail.com Date: Mon, 26 Nov 2012 11:53:39 -0500 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