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]

[RFC] Inlining functions with nested functions and dwarf2out


Hi,
debug/17389 is about dwarf2out aborting on function having nested functions
being fully inlined.  The actual reason is that "auto" keyword in the
declaration of function makes it to be missing in the BIND_EXPR list so
tree-inline never sees the function.  We are discussing the fix for this
with Joseph.
On the other hand we really ought to be able to inline these now we do all the
unnesting.  The (slight variant of) attached patch passes the testsuite and
it is able to build glibc.

I don't quite understand what consequences might have the idea of setting
parent to NULL in dwarf2out but it seems to be that it should not be very
critical.  Would be something like this acceptable?
(I am running the usual testing on ppc-linux now)

Honza

2004-09-21  Jan Hubicka  <jh@suse.cz>
	PR debug/17389
	* dwarf2out.c (dwarf2out_finish): Deal with nested functions
	of fully inlined functions.
	* tree-inline.c (inline_forbidden_p_1): Nested functions can be
	inlined.
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.547
diff -c -3 -p -r1.547 dwarf2out.c
*** dwarf2out.c	18 Sep 2004 05:50:42 -0000	1.547
--- dwarf2out.c	21 Sep 2004 00:11:29 -0000
*************** dwarf2out_finish (const char *filename)
*** 13554,13560 ****
  		 nested function can be optimized away, which results
  		 in the nested function die being orphaned.  Likewise
  		 with the return type of that nested function.  Force
! 		 this to be a child of the containing function.  */
  	      tree context = NULL_TREE;
  
  	      gcc_assert (node->created_for);
--- 13554,13565 ----
  		 nested function can be optimized away, which results
  		 in the nested function die being orphaned.  Likewise
  		 with the return type of that nested function.  Force
! 		 this to be a child of the containing function.
! 
! 		 It may happen that even the containing function got fully
! 		 inlined and optimized out.  In that case we are lost and
! 		 assign the empty child.  This should not be big issue as
! 		 the function is likely unreachable too.  */
  	      tree context = NULL_TREE;
  
  	      gcc_assert (node->created_for);
*************** dwarf2out_finish (const char *filename)
*** 13567,13574 ****
  	      gcc_assert (context && TREE_CODE (context) == FUNCTION_DECL);
  	      
  	      origin = lookup_decl_die (context);
! 	      gcc_assert (origin);
! 	      add_child_die (origin, die);
  	    }
  	}
      }
--- 13572,13579 ----
  	      gcc_assert (context && TREE_CODE (context) == FUNCTION_DECL);
  	      
  	      origin = lookup_decl_die (context);
! 	      if (origin)
! 	        add_child_die (origin, die);
  	    }
  	}
      }
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.142
diff -c -3 -p -r1.142 tree-inline.c
*** tree-inline.c	18 Sep 2004 05:50:44 -0000	1.142
--- tree-inline.c	21 Sep 2004 00:12:23 -0000
*************** inline_forbidden_p_1 (tree *nodep, int *
*** 993,1012 ****
  	  }
        break;
  
-     case BIND_EXPR:
-       for (t = BIND_EXPR_VARS (node); t ; t = TREE_CHAIN (t))
- 	{
-           /* We cannot inline functions that contain other functions.  */
- 	  if (TREE_CODE (t) == FUNCTION_DECL && DECL_INITIAL (t))
- 	    {
- 	      inline_forbidden_reason
- 		= N_("%Jfunction '%F' can never be inlined "
- 		     "because it contains a nested function");
- 	      return node;
- 	    }
- 	}
-       break;
- 
      case GOTO_EXPR:
        t = TREE_OPERAND (node, 0);
  
--- 993,998 ----


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