This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFH] Uses of output.h in the front ends


On Mon, Jun 4, 2012 at 3:34 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
>> have_global_bss_p:
>> cp/decl.c: ? ? ?&& !have_global_bss_p ())
>> ada/gcc-interface/utils.c: ? ? ?&& !have_global_bss_p ())
>>
>> I don't even know what this is. Help welcome. :-)
>
> Looks like premature optimization to me, better done in varpool_finalize_decl?

I thought so, too, but if you look at the code, then there are
comments explaining what these uses of have_global_bss_p are for.


The case in g++ depends on flag_conserve_space and that is a c-family
specific flag. This is the only use, btw. Here's the code:

  /* Tell the back end to use or not use .common as appropriate.  If we say
     -fconserve-space, we want this to save .data space, at the expense of
     wrong semantics.  If we say -fno-conserve-space, we want this to
     produce errors about redefs; to do this we force variables into the
     data segment.  */
  if (flag_conserve_space
      && TREE_CODE (decl) == VAR_DECL
      && TREE_PUBLIC (decl)
      && !DECL_THREAD_LOCAL_P (decl)
      && !have_global_bss_p ())
    DECL_COMMON (decl) = 1;

Note the "at the expense of wrong semantics", egad! The
-fconserve-space flag was introduced at r11952 by mrs. That revision
was done on May 7, 1996, with commit comment: "86th Cygnus<->FSF quick
merge". There is one test cases for this flag in testsuite/:
g++.old-deja/g++.brendan/array1.C:

Jason, is this flag something that we could deprecate for GCC 4.7 and remove?


The code for the case in Ada is this:

  /* Ada doesn't feature Fortran-like COMMON variables so we shouldn't
     try to fiddle with DECL_COMMON.  However, on platforms that don't
     support global BSS sections, uninitialized global variables would
     go in DATA instead, thus increasing the size of the executable.  */
  if (!flag_no_common
      && TREE_CODE (var_decl) == VAR_DECL
      && TREE_PUBLIC (var_decl)
      && !have_global_bss_p ())
    DECL_COMMON (var_decl) = 1;

That does look like premature optimization to me, but I don't really
understand the comment, or the effect of this code. Eric, could you
please have a look at this and help me out?

Ciao!
Steven


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]