This is the mail archive of the gcc-patches@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]

PR 21728


Hi,
in the attached testcase there is dead nonlocal label (since we create
edges call->nonlocal label in the CFG and the outer function has no
call).  But since at -O0/-O1 we emit the q() we get undefined label in
assembly output.

The attached patch fix it by deferring all nested functions to the very
end of compilation so they are output only when referenced.  Seems
resonable?

int
main (void)
{
  __label__ l1;
  void q (void)
  {
    goto l1;
  }

l1:;
}
2005-06-08  Jan Hubicka  <jh@suse.cz>
	* cgraphunit.c (decide_is_function_needed): Deffer all nested
	functions.

Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.116
diff -c -3 -p -r1.116 cgraphunit.c
*** cgraphunit.c	4 Jun 2005 20:23:13 -0000	1.116
--- cgraphunit.c	7 Jun 2005 20:35:29 -0000
*************** static FILE *cgraph_dump_file;
*** 188,195 ****
  static bool
  decide_is_function_needed (struct cgraph_node *node, tree decl)
  {
-   tree origin;
- 
    /* If the user told us it is used, then it must be so.  */
    if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
      return true;
--- 188,193 ----
*************** decide_is_function_needed (struct cgraph
*** 227,237 ****
    if (DECL_EXTERNAL (decl))
      return false;
    /* Nested functions of extern inline function shall not be emit unless
!      we inlined the origin.  */
!   for (origin = decl_function_context (decl); origin;
!        origin = decl_function_context (origin))
!     if (DECL_EXTERNAL (origin))
!       return false;
    /* We want to emit COMDAT functions only when absolutely necessary.  */
    if (DECL_COMDAT (decl))
      return false;
--- 225,236 ----
    if (DECL_EXTERNAL (decl))
      return false;
    /* Nested functions of extern inline function shall not be emit unless
!      we inlined the origin.  
!      We also need to elliminate unrechable functions having nonlocal gotos
!      as otherwise it dificult to keep the seemingly unreachable block not
!      optimized out.  */
!   if (decl_function_context (decl))
!     return false;
    /* We want to emit COMDAT functions only when absolutely necessary.  */
    if (DECL_COMDAT (decl))
      return false;


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