[backport gcc-4.9/trunk r198192, fixes PR57036 regression from PR56982 fix ] gcc/ 2013-04-23 Richard Biener PR middle-end/57036 * tree-inline.c (copy_edges_for_bb): Add can_make_abnormal_goto parameter, only add abnormal goto edges from the copied body if the call could perform abnormal gotos. (copy_cfg_body): Adjust. gcc/testsuite/ 2013-04-23 Richard Biener PR middle-end/57036 * gcc.dg/torture/pr57036-1.c: New testcase. * gcc.dg/torture/pr57036-2.c: Likewise. --- gcc-4.8.0/gcc/testsuite/gcc.dg/torture/pr57036-1.c.~1~ 1970-01-01 01:00:00.000000000 +0100 +++ gcc-4.8.0/gcc/testsuite/gcc.dg/torture/pr57036-1.c 2013-04-27 13:22:20.828606757 +0200 @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +extern void g (void); +extern __inline __attribute__ ((__always_inline__,__leaf__)) +f () +{ + g (); +} +struct __jmp_buf_tag *b; +int jpgDecode_convert (unsigned i) +{ + if (i != 0) + f (); + read_buf_open (); + return _setjmp (b); +} --- gcc-4.8.0/gcc/testsuite/gcc.dg/torture/pr57036-2.c.~1~ 1970-01-01 01:00:00.000000000 +0100 +++ gcc-4.8.0/gcc/testsuite/gcc.dg/torture/pr57036-2.c 2013-04-27 13:22:20.828606757 +0200 @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +int j_; +int jpgDecode_convert (unsigned i) +{ + __label__ label; + int j; + + inline void __attribute__((always_inline,leaf)) f(void) + { + g(); + } + + void __attribute__((noinline)) read_buf_open (void) + { + goto label; + } + + if (i != 0) + f (); + j = j_; + read_buf_open (); +label: + return j; +} --- gcc-4.8.0/gcc/tree-inline.c.~1~ 2013-03-08 12:29:06.000000000 +0100 +++ gcc-4.8.0/gcc/tree-inline.c 2013-04-27 13:22:20.828606757 +0200 @@ -1867,7 +1867,8 @@ update_ssa_across_abnormal_edges (basic_ debug stmts are left after a statement that must end the basic block. */ static bool -copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb) +copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb, + bool can_make_abnormal_goto) { basic_block new_bb = (basic_block) bb->aux; edge_iterator ei; @@ -1921,7 +1922,11 @@ copy_edges_for_bb (basic_block bb, gcov_ into a COMPONENT_REF which doesn't. If the copy can throw, the original could also throw. */ can_throw = stmt_can_throw_internal (copy_stmt); - nonlocal_goto = stmt_can_make_abnormal_goto (copy_stmt); + /* If the call we inline cannot make abnormal goto do not add + additional abnormal edges but only retain those already present + in the original function body. */ + nonlocal_goto + = can_make_abnormal_goto && stmt_can_make_abnormal_goto (copy_stmt); if (can_throw || nonlocal_goto) { @@ -2266,10 +2271,13 @@ copy_cfg_body (copy_body_data * id, gcov last = last_basic_block; /* Now that we've duplicated the blocks, duplicate their edges. */ + bool can_make_abormal_goto + = id->gimple_call && stmt_can_make_abnormal_goto (id->gimple_call); FOR_ALL_BB_FN (bb, cfun_to_copy) if (!blocks_to_copy || (bb->index > 0 && bitmap_bit_p (blocks_to_copy, bb->index))) - need_debug_cleanup |= copy_edges_for_bb (bb, count_scale, exit_block_map); + need_debug_cleanup |= copy_edges_for_bb (bb, count_scale, exit_block_map, + can_make_abormal_goto); if (new_entry) {