From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1478 invoked by alias); 1 Jul 2009 10:47:35 -0000 Received: (qmail 1430 invoked by alias); 1 Jul 2009 10:47:23 -0000 Date: Wed, 01 Jul 2009 10:47:00 -0000 Message-ID: <20090701104723.1429.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/40585] [4.3/4.4/4.5 Regression] tracer duplicates blocks w/o adjusting EH tree In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "hubicka at ucw dot cz" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00026.txt.bz2 ------- Comment #4 from hubicka at ucw dot cz 2009-07-01 10:47 ------- Subject: Re: [4.3/4.4/4.5 Regression] tracer duplicates blocks w/o adjusting EH tree Hi, the following patch should prevent tracer from copying resx. It is remarkably ugly I need to unconstify all the copy_bb_p predicates, so perhaps I will look into fixing the RTL expanders to allow multiple RESX blocks instead. Index: cfghooks.c =================================================================== --- cfghooks.c (revision 149102) +++ cfghooks.c (working copy) @@ -874,7 +874,7 @@ tidy_fallthru_edges (void) /* Returns true if we can duplicate basic block BB. */ bool -can_duplicate_block_p (const_basic_block bb) +can_duplicate_block_p (basic_block bb) { if (!cfg_hooks->can_duplicate_block_p) internal_error ("%s does not support can_duplicate_block_p", Index: cfghooks.h =================================================================== --- cfghooks.h (revision 149102) +++ cfghooks.h (working copy) @@ -75,7 +75,7 @@ struct cfg_hooks bool (*predicted_by_p) (const_basic_block bb, enum br_predictor predictor); /* Return true when block A can be duplicated. */ - bool (*can_duplicate_block_p) (const_basic_block a); + bool (*can_duplicate_block_p) (basic_block a); /* Duplicate block A. */ basic_block (*duplicate_block) (basic_block a); @@ -160,7 +160,7 @@ extern void tidy_fallthru_edge (edge); extern void tidy_fallthru_edges (void); extern void predict_edge (edge e, enum br_predictor predictor, int probability); extern bool predicted_by_p (const_basic_block bb, enum br_predictor predictor); -extern bool can_duplicate_block_p (const_basic_block); +extern bool can_duplicate_block_p (basic_block); extern basic_block duplicate_block (basic_block, edge, basic_block); extern bool block_ends_with_call_p (basic_block bb); extern bool block_ends_with_condjump_p (const_basic_block bb); Index: bb-reorder.c =================================================================== --- bb-reorder.c (revision 149102) +++ bb-reorder.c (working copy) @@ -176,7 +176,7 @@ static basic_block copy_bb (basic_block, static fibheapkey_t bb_to_key (basic_block); static bool better_edge_p (const_basic_block, const_edge, int, int, int, int, const_edge); static void connect_traces (int, struct trace *); -static bool copy_bb_p (const_basic_block, int); +static bool copy_bb_p (basic_block, int); static int get_uncond_jump_length (void); static bool push_to_next_round_p (const_basic_block, int, int, int, gcov_type); static void find_rarely_executed_basic_blocks_and_crossing_edges (edge **, @@ -1157,7 +1157,7 @@ connect_traces (int n_traces, struct tra when code size is allowed to grow by duplication. */ static bool -copy_bb_p (const_basic_block bb, int code_may_grow) +copy_bb_p (basic_block bb, int code_may_grow) { int size = 0; int max_size = uncond_jump_length; Index: tree-cfg.c =================================================================== --- tree-cfg.c (revision 149102) +++ tree-cfg.c (working copy) @@ -5131,8 +5131,17 @@ gimple_move_block_after (basic_block bb, /* Return true if basic_block can be duplicated. */ static bool -gimple_can_duplicate_bb_p (const_basic_block bb ATTRIBUTE_UNUSED) +gimple_can_duplicate_bb_p (basic_block bb) { + gimple_stmt_iterator gsi = gsi_last_bb (bb); + + /* RTL expander has quite artificial limitation to at most one RESX instruction + per region. It can be fixed by turning 1-1 map to 1-many map, but since the + code needs to be rewritten to gimple level lowering and there is little reason + for duplicating RESX instructions in order to optimize code performance, we + just disallow it for the moment. */ + if (!gsi_end_p (gsi) && gimple_code (gsi_stmt (gsi)) == GIMPLE_RESX) + return false; return true; } Index: cfgrtl.c =================================================================== --- cfgrtl.c (revision 149102) +++ cfgrtl.c (working copy) @@ -3161,7 +3161,7 @@ struct cfg_hooks rtl_cfg_hooks = { should only be used through the cfghooks interface, and we do not want to move them here since it would require also moving quite a lot of related code. They are in cfglayout.c. */ -extern bool cfg_layout_can_duplicate_bb_p (const_basic_block); +extern bool cfg_layout_can_duplicate_bb_p (basic_block); extern basic_block cfg_layout_duplicate_bb (basic_block); struct cfg_hooks cfg_layout_rtl_cfg_hooks = { -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40585