From d6d5ab2d7cc0a06c9e623d37949b98d1ce332ce2 Mon Sep 17 00:00:00 2001 From: hubicka Date: Mon, 30 Mar 2009 22:35:22 +0000 Subject: [PATCH] * tree-eh.c (make_eh_edges): Set probability 100% to first edge out of RESX. (tree_remove_unreachable_handlers): Cleanup EH predecestor detection and label handling. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145322 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/tree-eh.c | 39 ++++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c01e6ad..7509e62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-03-30 Jan Hubicka + + * tree-eh.c (make_eh_edges): Set probability 100% to first edge out of RESX. + (tree_remove_unreachable_handlers): Cleanup EH predecestor detection and label + handling. + 2009-03-30 Vladimir Makarov * ira-int.h (ira_allocno): Rename left_conflicts_num to diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 20e62ed..f55a417 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -1974,6 +1974,7 @@ make_eh_edges (gimple stmt) int region_nr; bool is_resx; bool inlinable = false; + basic_block bb; if (gimple_code (stmt) == GIMPLE_RESX) { @@ -1990,6 +1991,13 @@ make_eh_edges (gimple stmt) } foreach_reachable_handler (region_nr, is_resx, inlinable, make_eh_edge, stmt); + + /* Make CFG profile more consistent assuming that exception will resume to first + available EH handler. In practice this makes little difference, but we get + fewer consistency errors in the dumps. */ + bb = gimple_bb (stmt); + if (is_resx && EDGE_COUNT (bb->succs)) + EDGE_SUCC (bb, 0)->probability = REG_BR_PROB_BASE; } static bool mark_eh_edge_found_error; @@ -2659,12 +2667,7 @@ tree_remove_unreachable_handlers (void) { gimple_stmt_iterator gsi; int region; - bool has_eh_preds = false; - edge e; - edge_iterator ei; - - FOR_EACH_EDGE (e, ei, bb->preds) if (e->flags & EDGE_EH) - has_eh_preds = true; + bool has_eh_preds = bb_has_eh_pred (bb); for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { @@ -2673,11 +2676,8 @@ tree_remove_unreachable_handlers (void) if (gimple_code (stmt) == GIMPLE_LABEL && has_eh_preds) { int uid = LABEL_DECL_UID (gimple_label_label (stmt)); - if (uid <= cfun->cfg->last_label_uid) - { - int region = VEC_index (int, label_to_region, uid); - SET_BIT (reachable, region); - } + int region = VEC_index (int, label_to_region, uid); + SET_BIT (reachable, region); } if (gimple_code (stmt) == RESX) SET_BIT (reachable, gimple_resx_region (stmt)); @@ -2824,14 +2824,15 @@ cleanup_empty_eh (basic_block bb) if (!stmt_can_throw_internal (last_stmt (src))) continue; make_eh_edges (last_stmt (src)); - FOR_EACH_EDGE (e, ei, src->succs) if (e->flags & EDGE_EH) - { - dominance_info_invalidated = true; - for (si = gsi_start_phis (e->dest); !gsi_end_p (si); - gsi_next (&si)) - mark_sym_for_renaming (SSA_NAME_VAR - (PHI_RESULT (gsi_stmt (si)))); - } + FOR_EACH_EDGE (e, ei, src->succs) + if (e->flags & EDGE_EH) + { + dominance_info_invalidated = true; + for (si = gsi_start_phis (e->dest); !gsi_end_p (si); + gsi_next (&si)) + mark_sym_for_renaming (SSA_NAME_VAR + (PHI_RESULT (gsi_stmt (si)))); + } } if (dump_file) fprintf (dump_file, "Empty EH handler %i removed\n", region); -- 2.7.4