This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[pretty-ipa] Fix first part of fallout from a-i merge
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, mjambor at suse dot de
- Date: Fri, 3 Apr 2009 23:15:37 +0200
- Subject: [pretty-ipa] Fix first part of fallout from a-i merge
Hi,
this patch fixes early failures in bootstrap introduced by mainline
merge. Still new SRA is not working (I hope Martin will look into this)
and I am looking for further problems.
Honza
Index: ChangeLog.pretty-ipa
===================================================================
*** ChangeLog.pretty-ipa (revision 145500)
--- ChangeLog.pretty-ipa (working copy)
***************
*** 1,5 ****
--- 1,18 ----
2009-04-03 Jan Hubicka <jh@suse.cz>
+ * cgraph.c (cgraph_remove_node_and_inline_clones): New function.
+ * cgraph.h (cgraph_remove_node_and_inline_clones): Declare.
+ * cgraphunit.c (cgraph_materialize_clone): Initialize bitmap obstacks.
+ (cgraph_matherialize_clone): Update SSA.
+ * tree-inline.c (delete_unreachable_blocks_update_callgraph): New
+ function.
+ (tree_function_versioning): Rebuild SSA always and update cgraph
+ accordingly.
+ * passes.c: Temporarily switch back to original SRA.
+ * tree-cfgcleanup.c (merge_phi_nodes): Do not delete live SSA name.
+
+ 2009-04-03 Jan Hubicka <jh@suse.cz>
+
Merge from mainline.
2009-04-02 Jan Hubicka <jh@suse.cz>
Index: cgraph.c
===================================================================
*** cgraph.c (revision 145492)
--- cgraph.c (working copy)
*************** cgraph_remove_node (struct cgraph_node *
*** 1199,1204 ****
--- 1199,1218 ----
free_nodes = node;
}
+ /* Remove the node from cgraph. */
+
+ void
+ cgraph_remove_node_and_inline_clones (struct cgraph_node *node)
+ {
+ struct cgraph_edge *e, *next;
+ for (e = node->callees; e; e = next)
+ {
+ next = e->next_callee;
+ if (!e->inline_failed)
+ cgraph_remove_node_and_inline_clones (e->callee);
+ }
+ }
+
/* Notify finalize_compilation_unit that given node is reachable. */
void
Index: cgraph.h
===================================================================
*** cgraph.h (revision 145495)
--- cgraph.h (working copy)
*************** void debug_cgraph_node (struct cgraph_no
*** 342,347 ****
--- 342,348 ----
void cgraph_insert_node_to_hashtable (struct cgraph_node *node);
void cgraph_remove_edge (struct cgraph_edge *);
void cgraph_remove_node (struct cgraph_node *);
+ void cgraph_remove_node_and_inline_clones (struct cgraph_node *);
void cgraph_release_function_body (struct cgraph_node *);
void cgraph_node_remove_callees (struct cgraph_node *node);
struct cgraph_edge *cgraph_create_edge (struct cgraph_node *,
Index: cgraphunit.c
===================================================================
*** cgraphunit.c (revision 145492)
--- cgraphunit.c (working copy)
*************** save_inline_function_body (struct cgraph
*** 1674,1679 ****
--- 1674,1680 ----
static void
cgraph_materialize_clone (struct cgraph_node *node)
{
+ bitmap_obstack_initialize (NULL);
/* Copy the OLD_VERSION_NODE function tree to the new version. */
tree_function_versioning (node->clone_of->decl, node->decl,
node->clone.tree_map, true,
*************** cgraph_materialize_clone (struct cgraph_
*** 1689,1694 ****
--- 1690,1696 ----
node->next_sibling_clone = NULL;
node->prev_sibling_clone = NULL;
node->clone_of = NULL;
+ bitmap_obstack_release (NULL);
}
/* Once all functions from compilation unit are in memory, produce all clones
*************** cgraph_materialize_all_clones (void)
*** 1763,1768 ****
--- 1765,1773 ----
e->callee->clone.args_to_skip);
else
new_stmt = e->call_stmt;
+ if (gimple_vdef (new_stmt)
+ && TREE_CODE (gimple_vdef (new_stmt)) == SSA_NAME)
+ SSA_NAME_DEF_STMT (gimple_vdef (new_stmt)) = new_stmt;
gimple_call_set_fndecl (new_stmt, e->callee->decl);
gsi = gsi_for_stmt (e->call_stmt);
Index: tree-cfgcleanup.c
===================================================================
*** tree-cfgcleanup.c (revision 145492)
--- tree-cfgcleanup.c (working copy)
*************** merge_phi_nodes (void)
*** 928,933 ****
--- 928,947 ----
tree result = gimple_phi_result (phi);
if (!result_ok_for_phi_merging (result, dest, dest_idx))
{
+ imm_use_iterator iter;
+ use_operand_p use_p;
+ gimple stmt;
+
+ /* As we are going to delete this block we will release all
+ defs which makes the immediate uses on use stmts invalid.
+ Avoid that by replacing all uses with the bare variable
+ and updating the stmts. */
+ FOR_EACH_IMM_USE_STMT (stmt, iter, result)
+ {
+ FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+ SET_USE (use_p, SSA_NAME_VAR (result));
+ update_stmt (stmt);
+ }
update_ssa = true;
mark_sym_for_renaming (SSA_NAME_VAR
(PHI_RESULT (gsi_stmt (gsi))));
Index: tree-inline.c
===================================================================
*** tree-inline.c (revision 145500)
--- tree-inline.c (working copy)
*************** tree_versionable_function_p (tree fndecl
*** 4870,4875 ****
--- 4870,4944 ----
return true;
}
+ /* Delete all unreachable basic blocks and update callgraph.
+ Doing so is somewhat nontrivial because we need to update all clones and
+ remove inline function that become unreachable. */
+
+ static bool
+ delete_unreachable_blocks_update_callgraph (copy_body_data *id)
+ {
+ bool changed = false;
+ basic_block b, next_bb;
+
+ find_unreachable_blocks ();
+
+ /* Delete all unreachable basic blocks. */
+
+ for (b = ENTRY_BLOCK_PTR->next_bb; b != EXIT_BLOCK_PTR; b = next_bb)
+ {
+ next_bb = b->next_bb;
+
+ if (!(b->flags & BB_REACHABLE))
+ {
+ gimple_stmt_iterator bsi;
+
+ for (bsi = gsi_start_bb (b); !gsi_end_p (bsi); gsi_next (&bsi))
+ if (gimple_code (gsi_stmt (bsi)) == GIMPLE_CALL)
+ {
+ struct cgraph_edge *e;
+ struct cgraph_node *node;
+
+ if ((e = cgraph_edge (id->dst_node, gsi_stmt (bsi))) != NULL)
+ {
+ if (!e->inline_failed)
+ cgraph_remove_node_and_inline_clones (e->callee);
+ else
+ cgraph_remove_edge (e);
+ }
+ if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES)
+ for (node = id->dst_node->clones; node != id->dst_node;)
+ {
+ if ((e = cgraph_edge (id->dst_node, gsi_stmt (bsi))) != NULL)
+ {
+ if (!e->inline_failed)
+ cgraph_remove_node_and_inline_clones (e->callee);
+ else
+ cgraph_remove_edge (e);
+ }
+
+ if (node->clones)
+ node = node->clones;
+ else if (node->next_sibling_clone)
+ node = node->next_sibling_clone;
+ else
+ {
+ while (node != id->dst_node && !node->next_sibling_clone)
+ node = node->clone_of;
+ if (node != id->dst_node)
+ node = node->next_sibling_clone;
+ }
+ }
+ }
+ delete_basic_block (b);
+ changed = true;
+ }
+ }
+
+ if (changed)
+ tidy_fallthru_edges ();
+ return changed;
+ }
+
/* Create a copy of a function's tree.
OLD_DECL and NEW_DECL are FUNCTION_DECL tree nodes
of the original function and the new copied function
*************** tree_function_versioning (tree old_decl,
*** 4916,4923 ****
memset (&id, 0, sizeof (id));
/* Generate a new name for the new version. */
! if (!update_clones)
! id.statements_to_fold = pointer_set_create ();
id.decl_map = pointer_map_create ();
id.src_fn = old_decl;
--- 4985,4991 ----
memset (&id, 0, sizeof (id));
/* Generate a new name for the new version. */
! id.statements_to_fold = pointer_set_create ();
id.decl_map = pointer_map_create ();
id.src_fn = old_decl;
*************** tree_function_versioning (tree old_decl,
*** 5035,5048 ****
pointer_map_destroy (id.decl_map);
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
! if (!update_clones)
! {
! fold_marked_statements (0, id.statements_to_fold);
! pointer_set_destroy (id.statements_to_fold);
! fold_cond_expr_cond ();
! delete_unreachable_blocks ();
! update_ssa (TODO_update_ssa);
! }
VEC_free (gimple, heap, init_stmts);
pop_cfun ();
current_function_decl = old_current_function_decl;
--- 5103,5117 ----
pointer_map_destroy (id.decl_map);
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
!
! fold_marked_statements (0, id.statements_to_fold);
! pointer_set_destroy (id.statements_to_fold);
! fold_cond_expr_cond ();
! delete_unreachable_blocks_update_callgraph (&id);
! update_ssa (TODO_update_ssa);
! free_dominance_info (CDI_DOMINATORS);
! free_dominance_info (CDI_POST_DOMINATORS);
!
VEC_free (gimple, heap, init_stmts);
pop_cfun ();
current_function_decl = old_current_function_decl;
Index: passes.c
===================================================================
*** passes.c (revision 145500)
--- passes.c (working copy)
*************** init_optimization_passes (void)
*** 555,561 ****
NEXT_PASS (pass_ccp);
NEXT_PASS (pass_forwprop);
NEXT_PASS (pass_update_address_taken);
! #if 0 /* !!!!!!!!!!!!! */
NEXT_PASS (pass_sra_early);
#else
NEXT_PASS (pass_early_new_sra);
--- 555,561 ----
NEXT_PASS (pass_ccp);
NEXT_PASS (pass_forwprop);
NEXT_PASS (pass_update_address_taken);
! #if 1 /* !!!!!!!!!!!!! */
NEXT_PASS (pass_sra_early);
#else
NEXT_PASS (pass_early_new_sra);
*************** init_optimization_passes (void)
*** 563,569 ****
--- 563,571 ----
NEXT_PASS (pass_copy_prop);
NEXT_PASS (pass_merge_phi);
NEXT_PASS (pass_cd_dce);
+ #if 0
NEXT_PASS (pass_early_ipa_sra);
+ #endif
NEXT_PASS (pass_tail_recursion);
NEXT_PASS (pass_convert_switch);
NEXT_PASS (pass_cleanup_eh);
*************** init_optimization_passes (void)
*** 627,633 ****
NEXT_PASS (pass_ch);
NEXT_PASS (pass_stdarg);
NEXT_PASS (pass_lower_complex);
! #if 0 /* !!!!!!!!!!!!! */
NEXT_PASS (pass_sra);
#else
NEXT_PASS (pass_new_sra);
--- 629,635 ----
NEXT_PASS (pass_ch);
NEXT_PASS (pass_stdarg);
NEXT_PASS (pass_lower_complex);
! #if 1 /* !!!!!!!!!!!!! */
NEXT_PASS (pass_sra);
#else
NEXT_PASS (pass_new_sra);