[Bug debug/21828] [4.0/4.1 Regression] debug info omitted for global variables

mark at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Mon Jun 6 00:16:00 GMT 2005


------- Additional Comments From mark at codesourcery dot com  2005-06-06 00:15 -------
Subject: Re:  [4.0/4.1 Regression] debug info omitted for
 global variables

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-05 23:50 -------
> (In reply to comment #3)
> 
>>Is there a test case for this bug?  (The usual things: preprocessed source,
>>command-line, etc.?)
> 
> From <http://gcc.gnu.org/ml/gcc/2005-05/msg01635.html>:
> 
> You can reproduce it using:
> static int i;
> int main(void)
> {
>   i += 3;
>   i *= 5;
>   return 0;
> }
> 
> and readelf and looking for the DW_TAG_variable tag.

Thanks.  I can see the problem, when compiling with -O2.

I'm not really sure yet whether this is my fault, or whether some 
subsequent change to cgraph after my changes got checked in broke things.

In any case, I'm don't think that the code I wrote in 
check_global_declarations is wrong, in and of itself.  If 
check_global_declarations is going to be responsible for calling 
debug_hooks->global_decl, then we must set DECL_IGNORED_P correctly by 
that point.  (That assume that, in fact, we should not put out debugging 
information about variables that have been optimized away; I think that 
assumption is correct in that we might otherwise get relocations against 
them, at least in some debugging formats.)

But, the way things are set up, we apparently don't really know whether 
or not we're going to output the variables until cgraph_optimize, which 
is not called until later in c_write_global_declarations.

That suggests that perhaps the correct fix is to move the call to 
debug_hooks->global_decl into cgraph, or have it in both places.  Or, 
perhaps cgraph_optimize should be called before check_global_declarations.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21828



More information about the Gcc-bugs mailing list