This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[middle-end, patch 2/3] Update ipa-prop structures during all kinds of inlining
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Jan Hubicka <jh at suse dot cz>, Kenneth Zadeck <zadeck at naturalbridge dot com>, Razya Ladelsky <RAZYA at il dot ibm dot com>, Tomas Bily <tbily at suse dot cz>
- Date: Wed, 10 Sep 2008 17:56:10 +0200
- Subject: [middle-end, patch 2/3] Update ipa-prop structures during all kinds of inlining
- References: <20080910155608.630827941@alvy.suse.cz>
This patch simplifies the inlining code a little bit by making
cgraph_mark_inline_edge invoke indirect inlining updates rather than
mandating the caller does that immediately afterwards.
This is not only a cleanup but actually ensures that the structures
are updated in all cases, whereas I am not really that sure they are
as it is now.
2008-09-10 Martin Jambor <mjambor@suse.cz>
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
Index: iinln/gcc/cgraph.h
===================================================================
--- iinln.orig/gcc/cgraph.h 2008-09-07 19:23:43.000000000 +0200
+++ iinln/gcc/cgraph.h 2008-09-10 15:23:34.000000000 +0200
@@ -452,7 +452,6 @@ varpool_next_static_initializer (struct
/* In ipa-inline.c */
void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
-void cgraph_mark_inline_edge (struct cgraph_edge *, bool);
bool cgraph_default_inline_p (struct cgraph_node *, const char **);
unsigned int compute_inline_parameters (struct cgraph_node *);
Index: iinln/gcc/ipa-inline.c
===================================================================
--- iinln.orig/gcc/ipa-inline.c 2008-09-10 14:15:43.000000000 +0200
+++ iinln/gcc/ipa-inline.c 2008-09-10 15:23:34.000000000 +0200
@@ -243,15 +243,18 @@ cgraph_clone_inlined_nodes (struct cgrap
cgraph_clone_inlined_nodes (e, duplicate, update_original);
}
-/* Mark edge E as inlined and update callgraph accordingly.
- UPDATE_ORIGINAL specify whether profile of original function should be
- updated. */
+/* Mark edge E as inlined and update callgraph accordingly. UPDATE_ORIGINAL
+ specify whether profile of original function should be updated. If any new
+ indirect edges are discovered in the process, add them to NEW_EDGES, unless
+ it is NULL. */
-void
-cgraph_mark_inline_edge (struct cgraph_edge *e, bool update_original)
+static void
+cgraph_mark_inline_edge (struct cgraph_edge *e, bool update_original,
+ VEC (cgraph_edge_p, heap) *new_edges)
{
int old_insns = 0, new_insns = 0;
struct cgraph_node *to = NULL, *what;
+ struct cgraph_edge *curr = e;
if (e->callee->inline_decl)
cgraph_redirect_edge_callee (e, cgraph_node (e->callee->inline_decl));
@@ -281,6 +284,9 @@ cgraph_mark_inline_edge (struct cgraph_e
if (new_insns > old_insns)
overall_insns += new_insns - old_insns;
ncalls_inlined++;
+
+ if (flag_indirect_inlining)
+ ipa_propagate_indirect_call_infos (curr, new_edges);
}
/* Mark all calls of EDGE->CALLEE inlined into EDGE->CALLER.
@@ -302,7 +308,7 @@ cgraph_mark_inline (struct cgraph_edge *
next = e->next_caller;
if (e->caller == to && e->inline_failed)
{
- cgraph_mark_inline_edge (e, true);
+ cgraph_mark_inline_edge (e, true, NULL);
if (e == edge)
edge = next;
}
@@ -746,9 +752,7 @@ cgraph_decide_recursive_inlining (struct
fprintf (dump_file, "\n");
}
cgraph_redirect_edge_callee (curr, master_clone);
- cgraph_mark_inline_edge (curr, false);
- if (flag_indirect_inlining)
- ipa_propagate_indirect_call_infos (curr, new_edges);
+ cgraph_mark_inline_edge (curr, false, new_edges);
lookup_recursive_calls (node, curr->callee, heap);
n++;
}
@@ -999,12 +1003,10 @@ cgraph_decide_inlining_of_small_function
continue;
}
callee = edge->callee;
- cgraph_mark_inline_edge (edge, true);
+ cgraph_mark_inline_edge (edge, true, new_indirect_edges);
if (flag_indirect_inlining)
- {
- ipa_propagate_indirect_call_infos (edge, new_indirect_edges);
- add_new_edges_to_heap (heap, new_indirect_edges);
- }
+ add_new_edges_to_heap (heap, new_indirect_edges);
+
update_callee_keys (heap, callee, updated_nodes);
}
where = edge->caller;
@@ -1135,9 +1137,7 @@ cgraph_decide_inlining (void)
gimple_call_set_cannot_inline (e->call_stmt, true);
continue;
}
- cgraph_mark_inline_edge (e, true);
- if (flag_indirect_inlining)
- ipa_propagate_indirect_call_infos (e, NULL);
+ cgraph_mark_inline_edge (e, true, NULL);
if (dump_file)
fprintf (dump_file,
" Inlined into %s which now has %i insns.\n",
@@ -1158,11 +1158,6 @@ cgraph_decide_inlining (void)
cgraph_decide_inlining_of_small_functions ();
- /* After this point, any edge discovery performed by indirect inlining is no
- good so let's give up. */
- if (flag_indirect_inlining)
- free_all_ipa_structures_after_iinln ();
-
if (flag_inline_functions_called_once)
{
if (dump_file)
@@ -1217,6 +1212,10 @@ cgraph_decide_inlining (void)
}
}
+ /* Free ipa-prop structures if they are no longer needed. */
+ if (flag_indirect_inlining)
+ free_all_ipa_structures_after_iinln ();
+
if (dump_file)
fprintf (dump_file,
"\nInlined %i calls, eliminated %i functions, "
Index: iinln/gcc/ipa-prop.c
===================================================================
--- iinln.orig/gcc/ipa-prop.c 2008-09-10 14:39:29.000000000 +0200
+++ iinln/gcc/ipa-prop.c 2008-09-10 16:19:53.000000000 +0200
@@ -992,6 +992,12 @@ void
ipa_propagate_indirect_call_infos (struct cgraph_edge *cs,
VEC (cgraph_edge_p, heap) *new_edges)
{
+ /* Do nothing if the preparation phase has not been carried out yet
+ (i.e. during early inlining). */
+ if (!ipa_node_params_vector)
+ return;
+ gcc_assert (ipa_edge_args_vector);
+
propagate_info_to_inlined_callees (cs, cs->callee, new_edges);
}
--