This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Fix cgraph node duplication code
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 9 Jan 2004 20:57:36 +0100
- Subject: [tree-ssa] Fix cgraph node duplication code
Hi,
I've bootstrapped & regtested this patch and will commit it as obivous.
It adds sanity check that function body size is never negative and fix
one extra case where I got updating of CFG wrong. It does not affect
anything, but makes things more correct.
Honza
2004-01-09 Jan Hubicka <jh@suse.cz>
* cgraph.h (cgraph_clone_inlined_nodes): Declare.
* cgraphunit.c (cgrpah_clone_inlined_nodes): Make global.
(cgraph_mark_inline_edge): Sanity check that size is positive.
(cgraph_decide_inlining): Fix typo.
* tree-optimize.c (tree_rest_of_compilation): Fix node duplication
code.
Index: cgraph.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.h,v
retrieving revision 1.1.4.14
diff -c -3 -p -r1.1.4.14 cgraph.h
*** cgraph.h 4 Jan 2004 15:48:30 -0000 1.1.4.14
--- cgraph.h 9 Jan 2004 17:56:52 -0000
*************** bool cgraph_preserve_function_body_p (tr
*** 192,196 ****
--- 192,197 ----
void verify_cgraph (void);
void verify_cgraph_node (struct cgraph_node *);
void cgraph_mark_inline_edge (struct cgraph_edge *e);
+ void cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate);
#endif /* GCC_CGRAPH_H */
Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.1.4.29
diff -c -3 -p -r1.1.4.29 cgraphunit.c
*** cgraphunit.c 4 Jan 2004 15:48:30 -0000 1.1.4.29
--- cgraphunit.c 9 Jan 2004 17:56:52 -0000
*************** cgraph_estimate_growth (struct cgraph_no
*** 826,832 ****
DUPLICATE is used for bookeeping on whether we are actually creating new
clones or re-using node originally representing out-of-line function call.
*/
! static void
cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate)
{
struct cgraph_node *n;
--- 826,832 ----
DUPLICATE is used for bookeeping on whether we are actually creating new
clones or re-using node originally representing out-of-line function call.
*/
! void
cgraph_clone_inlined_nodes (struct cgraph_edge *e, bool duplicate)
{
struct cgraph_node *n;
*************** cgraph_mark_inline_edge (struct cgraph_e
*** 894,899 ****
--- 894,901 ----
old_insns = e->caller->global.insns;
new_insns = cgraph_estimate_size_after_inlining (1, e->caller,
what);
+ if (new_insns < 0)
+ abort ();
to = e->caller;
to->global.insns = new_insns;
}
*************** cgraph_decide_inlining (void)
*** 1337,1343 ****
/* Verify that we won't duplicate the caller. */
for (node1 = node->callers->caller;
! node1->callers && node1->callers->inline_failed
&& ok; node1 = node1->callers->caller)
if (node1->callers->next_caller || node1->needed)
ok = false;
--- 1339,1345 ----
/* Verify that we won't duplicate the caller. */
for (node1 = node->callers->caller;
! node1->callers && !node1->callers->inline_failed
&& ok; node1 = node1->callers->caller)
if (node1->callers->next_caller || node1->needed)
ok = false;
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 1.1.4.104
diff -c -3 -p -r1.1.4.104 tree-optimize.c
*** tree-optimize.c 8 Jan 2004 20:08:57 -0000 1.1.4.104
--- tree-optimize.c 9 Jan 2004 17:56:52 -0000
*************** tree_rest_of_compilation (tree fndecl, b
*** 386,395 ****
saved_node = cgraph_clone_node (node);
for (e = saved_node->callees; e; e = e->next_callee)
if (!e->inline_failed)
! {
! e->inline_failed = "";
! cgraph_mark_inline_edge (e);
! }
}
cfun->saved_tree = save_body (fndecl, &cfun->saved_args);
}
--- 386,392 ----
saved_node = cgraph_clone_node (node);
for (e = saved_node->callees; e; e = e->next_callee)
if (!e->inline_failed)
! cgraph_clone_inlined_nodes (e, true);
}
cfun->saved_tree = save_body (fndecl, &cfun->saved_args);
}