Patchwork [RFC] Make the new var decl STATIC in function dw2_output_indirect_constant_1

login
register
mail settings
Submitter Carrot Wei
Date May 10, 2013, 6:27 p.m.
Message ID <CAEe8uEAiri4iC342wwoikxLFGOHKU_BrZ-2=-HhS7_UJy2ezGQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/243053/
State New
Headers show

Comments

Carrot Wei - May 10, 2013, 6:27 p.m.
Hi

In function dw2_output_indirect_constant_1 a new var decl is created. Only
When the variable is not PUBLIC it is allocated static storage. Does anybody
know why the variable is not allocated static storage by marking TREE_STATIC
when it is PUBLIC?

The following patch marks the STATIC flag in all cases. It can pass bootstrap
and regression test on x86-64.

Any comments?

thanks
Carrot


2013-05-09  Guozhi Wei  <carrot@google.com>

        * dwarf2asm.c (dw2_output_indirect_constant_1): Mark new decl STATIC.
Richard Guenther - May 13, 2013, 7:44 a.m.
On Fri, May 10, 2013 at 8:27 PM, Carrot Wei <carrot@google.com> wrote:
> Hi
>
> In function dw2_output_indirect_constant_1 a new var decl is created. Only
> When the variable is not PUBLIC it is allocated static storage. Does anybody
> know why the variable is not allocated static storage by marking TREE_STATIC
> when it is PUBLIC?

Beacuse TREE_STATIC says whether it gets static or external storage.  Not
all combinations of TREE_STATIC/TREE_PUBLIC/DECL_EXTERNAL make
sense (though you'll see very weird combinations from the C++ frontend which
also has DECL_REALLY_EXTERN).

> The following patch marks the STATIC flag in all cases. It can pass bootstrap
> and regression test on x86-64.
>
> Any comments?

Ok.

Thanks,
Richard.

> thanks
> Carrot
>
>
> 2013-05-09  Guozhi Wei  <carrot@google.com>
>
>         * dwarf2asm.c (dw2_output_indirect_constant_1): Mark new decl STATIC.
>
>
> Index: dwarf2asm.c
> ===================================================================
> --- dwarf2asm.c (revision 198794)
> +++ dwarf2asm.c (working copy)
> @@ -906,6 +906,7 @@
>    DECL_IGNORED_P (decl) = 1;
>    DECL_INITIAL (decl) = decl;
>    TREE_READONLY (decl) = 1;
> +  TREE_STATIC (decl) = 1;
>
>    if (TREE_PUBLIC (id))
>      {
> @@ -914,8 +915,6 @@
>        if (USE_LINKONCE_INDIRECT)
>   DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
>      }
> -  else
> -    TREE_STATIC (decl) = 1;
>
>    sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
>    assemble_variable (decl, 1, 1, 1);

Patch

Index: dwarf2asm.c
===================================================================
--- dwarf2asm.c (revision 198794)
+++ dwarf2asm.c (working copy)
@@ -906,6 +906,7 @@ 
   DECL_IGNORED_P (decl) = 1;
   DECL_INITIAL (decl) = decl;
   TREE_READONLY (decl) = 1;
+  TREE_STATIC (decl) = 1;

   if (TREE_PUBLIC (id))
     {
@@ -914,8 +915,6 @@ 
       if (USE_LINKONCE_INDIRECT)
  DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
     }
-  else
-    TREE_STATIC (decl) = 1;

   sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
   assemble_variable (decl, 1, 1, 1);