This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: put zero-initialized thread local variables in .tbss
- From: Richard Henderson <rth at redhat dot com>
- To: Jan Beulich <JBeulich at novell dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 7 Jul 2004 23:27:43 -0700
- Subject: Re: put zero-initialized thread local variables in .tbss
- References: <s0ebf65c.098@emea1-mh.id2.novell.com>
On Wed, Jul 07, 2004 at 02:11:30PM +0200, Jan Beulich wrote:
> @@ -135,11 +135,11 @@
> static void maybe_assemble_visibility (tree);
> static int in_named_entry_eq (const void *, const void *);
> static hashval_t in_named_entry_hash (const void *);
> +#ifdef BSS_SECTION_ASM_OP
> #ifdef ASM_OUTPUT_BSS
> static void asm_output_bss (FILE *, tree, const char *,
> unsigned HOST_WIDE_INT, unsigned
> HOST_WIDE_INT);
> #endif
> -#ifdef BSS_SECTION_ASM_OP
> #ifdef ASM_OUTPUT_ALIGNED_BSS
> static void asm_output_aligned_bss (FILE *, tree, const char *,
> unsigned HOST_WIDE_INT, int)
This bit wasn't in the ChangeLog. I applied it separately.
I modified the main portion of the patch like so.
r~
* varasm.c (assemble_variable): Use assemble_zeros for
zero-initialized variables.
(categorize_decl_for_section): Honor flag_zero_initialized_in_bss
for SECCAT_BSS and SECCAT_TBSS.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.431
diff -c -p -d -r1.431 varasm.c
*** varasm.c 8 Jul 2004 06:14:19 -0000 1.431
--- varasm.c 8 Jul 2004 06:22:05 -0000
*************** assemble_variable (tree decl, int top_le
*** 1563,1569 ****
if (!dont_output_data)
{
! if (DECL_INITIAL (decl) && DECL_INITIAL (decl) != error_mark_node)
/* Output the actual data. */
output_constant (DECL_INITIAL (decl),
tree_low_cst (DECL_SIZE_UNIT (decl), 1),
--- 1563,1571 ----
if (!dont_output_data)
{
! if (DECL_INITIAL (decl)
! && DECL_INITIAL (decl) != error_mark_node
! && !initializer_zerop (DECL_INITIAL (decl)))
/* Output the actual data. */
output_constant (DECL_INITIAL (decl),
tree_low_cst (DECL_SIZE_UNIT (decl), 1),
*************** categorize_decl_for_section (tree decl,
*** 4611,4617 ****
else if (TREE_CODE (decl) == VAR_DECL)
{
if (DECL_INITIAL (decl) == NULL
! || DECL_INITIAL (decl) == error_mark_node)
ret = SECCAT_BSS;
else if (! TREE_READONLY (decl)
|| TREE_SIDE_EFFECTS (decl)
--- 4613,4623 ----
else if (TREE_CODE (decl) == VAR_DECL)
{
if (DECL_INITIAL (decl) == NULL
! || DECL_INITIAL (decl) == error_mark_node
! || (flag_zero_initialized_in_bss
! /* Leave constant zeroes in .rodata so they can be shared. */
! && !TREE_READONLY (decl)
! && initializer_zerop (DECL_INITIAL (decl))))
ret = SECCAT_BSS;
else if (! TREE_READONLY (decl)
|| TREE_SIDE_EFFECTS (decl)
*************** categorize_decl_for_section (tree decl,
*** 4653,4659 ****
/* There are no read-only thread-local sections. */
if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
{
! if (ret == SECCAT_BSS)
ret = SECCAT_TBSS;
else
ret = SECCAT_TDATA;
--- 4659,4669 ----
/* There are no read-only thread-local sections. */
if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
{
! /* Note that this would be *just* SECCAT_BSS, except that there's
! no concept of a read-only thread-local-data section. */
! if (ret == SECCAT_BSS
! || (flag_zero_initialized_in_bss
! && initializer_zerop (DECL_INITIAL (decl))))
ret = SECCAT_TBSS;
else
ret = SECCAT_TDATA;