PR middle-end/25962

Jan Hubicka jh@suse.cz
Tue May 9 02:46:00 GMT 2006


Hi,
as disucssed in the PR, it seems to be good idea to not optimize out
static unused functions at -O0 to help debugging.

Bootstrapped/regtested i686-linux, going to commit it shortly.

2006-05-08  Jan Hubicka  <jh@suse.cz>
	PR middle-end/25962
	* cgraphunit.c (decide_is_function_needed): When not optimizing even
	unused static functions are needed.

	* gcc.dg/pr25962.c: New.

Index: cgraphunit.c
===================================================================
*** cgraphunit.c	(revision 113605)
--- cgraphunit.c	(working copy)
*************** decide_is_function_needed (struct cgraph
*** 216,223 ****
      return true;
  
    /* Externally visible functions must be output.  The exception is
!      COMDAT functions that must be output only when they are needed.  */
!   if ((TREE_PUBLIC (decl) && !flag_whole_program)
        && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
      return true;
  
--- 216,227 ----
      return true;
  
    /* Externally visible functions must be output.  The exception is
!      COMDAT functions that must be output only when they are needed. 
! 
!      When not optimizing, also output the static functions. (see
!      PR25962)
!      */
!   if (((TREE_PUBLIC (decl) || !optimize) && !flag_whole_program)
        && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
      return true;
  
Index: testsuite/gcc.dg/pr25962.c
===================================================================
*** testsuite/gcc.dg/pr25962.c	(revision 0)
--- testsuite/gcc.dg/pr25962.c	(revision 0)
***************
*** 0 ****
--- 1,6 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O0" } */
+ /* { dg-final { scan-assembler "debug_hook" } } */
+ static int debug_hook()
+ {
+ }



More information about the Gcc-patches mailing list