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]

[3.5/3.4] Fix bug in inlining WRT inlining function into itself


Hello,

when compiling my (relativelly large although minimal) testcase at -O3
I get a ICE in verify flow info with error message "Wrong amount of branch edges
after unconditional jump"
because of this insn:

(jump_insn 82 81 83 (set (pc)
        (label_ref 0)) -1 (nil)
	    (nil))

I analyzed how label_ref 0 came there and found the problem.

Function x gets inlined into y, and then y into x.
In the second inlining, we replace RETURN_STMT with GOTO ret_label
in copy_body_r () as usual.
But when we continue walking through the tree we reach the new
GOTO ret_label and make a copy of the ret_label because
(*lang_hooks.tree_inlining.auto_var_in_fn_p) (*tp, fn) == true
because DECL_CONTEXT (*tp) == fn  (see lhd_tree_inlining_auto_var_in_fn_p).
The copied ret_label is not of course emitted to code because it is not
elsewhere in the tree and gets expanded to that (label_ref 0).

The ret_label should not be copied because we inserted it there
in replacement of RETURN_STMT.
The following patch fixes it.
This happens only when inlining a function into itself via transitivity
thus it did not happen before (before unit at a time).

Bootstrapped/regtested x86-64.
OK for mainline and 3.4 branch?

Joe

2004-01-21  Josef Zlomek  <zlomekj@suse.cz>

	* tree-inline.c (copy_body_r): Do not replace ret_label.

Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc-cvs/gcc/gcc/tree-inline.c,v
retrieving revision 1.34.2.17
diff -c -p -c -3 -p -r1.34.2.17 tree-inline.c
*** tree-inline.c	3 Jan 2004 18:13:44 -0000	1.34.2.17
--- tree-inline.c	21 Jan 2004 18:17:32 -0000
*************** copy_body_r (tp, walk_subtrees, data)
*** 491,497 ****
       variables.  We don't want to copy static variables; there's only
       one of those, no matter how many times we inline the containing
       function.  */
!   else if ((*lang_hooks.tree_inlining.auto_var_in_fn_p) (*tp, fn))
      {
        tree new_decl;
  
--- 491,498 ----
       variables.  We don't want to copy static variables; there's only
       one of those, no matter how many times we inline the containing
       function.  */
!   else if (*tp != id->ret_label
! 	   && (*lang_hooks.tree_inlining.auto_var_in_fn_p) (*tp, fn))
      {
        tree new_decl;
  


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