From: Jakub Jelinek Date: Wed, 3 Jun 2015 21:33:22 +0000 (+0200) Subject: backport: re PR gcov-profile/64634 (gcov reports catch(...) as not executed) X-Git-Tag: releases/gcc-4.8.5~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f4b6e745249006d8cd39d7bf475cd5295350171;p=thirdparty%2Fgcc.git backport: re PR gcov-profile/64634 (gcov reports catch(...) as not executed) Backported from mainline 2015-02-18 Jakub Jelinek PR gcov-profile/64634 * tree-eh.c (frob_into_branch_around): Fix up typos in function comment. (lower_catch): Put eh_seq resulting from EH lowering of the cleanup sequence after the cleanup rather than before it. * g++.dg/gcov/gcov-15.C: New test. From-SVN: r224102 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da6c3426a6cc..5e502416bddd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2015-06-03 Jakub Jelinek + + Backported from mainline + 2015-02-18 Jakub Jelinek + + PR gcov-profile/64634 + * tree-eh.c (frob_into_branch_around): Fix up typos + in function comment. + (lower_catch): Put eh_seq resulting from EH lowering of + the cleanup sequence after the cleanup rather than before + it. + 2015-06-03 Richard Biener Backport from mainline diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b5a32359d49e..132c0f216a3a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2015-06-03 Jakub Jelinek + + Backported from mainline + 2015-02-18 Jakub Jelinek + + PR gcov-profile/64634 + * g++.dg/gcov/gcov-15.C: New test. + 2015-06-03 Richard Biener Backport from mainline diff --git a/gcc/testsuite/g++.dg/gcov/gcov-15.C b/gcc/testsuite/g++.dg/gcov/gcov-15.C new file mode 100644 index 000000000000..fcd16b00b1c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/gcov/gcov-15.C @@ -0,0 +1,26 @@ +// PR gcov-profile/64634 +// { dg-options "-fprofile-arcs -ftest-coverage" } +// { dg-do run { target native } } + +void catchEx () // count(1) +{ + __builtin_exit (0); // count(1) + try + {} + catch (int) + {} +} + +int main () // count(1) +{ + try + { + throw 5; // count(1) + } + catch (...) // count(1) + { + catchEx (); // count(1) + } +} + +// { dg-final { run-gcov gcov-15.C } } diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 902ce452791c..123ae997179b 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -828,10 +828,10 @@ eh_region_may_contain_throw (eh_region r) /* We want to transform try { body; } catch { stuff; } to - normal_seqence: + normal_sequence: body; over: - eh_seqence: + eh_sequence: landing_pad: stuff; goto over; @@ -1752,6 +1752,12 @@ lower_catch (struct leh_state *state, gimple tp) this_state.cur_region = state->cur_region; this_state.ehp_region = try_region; + /* Add eh_seq from lowering EH in the cleanup sequence after the cleanup + itself, so that e.g. for coverage purposes the nested cleanups don't + appear before the cleanup body. See PR64634 for details. */ + gimple_seq old_eh_seq = eh_seq; + eh_seq = NULL; + out_label = NULL; cleanup = gimple_try_cleanup (tp); for (gsi = gsi_start (cleanup); @@ -1788,7 +1794,11 @@ lower_catch (struct leh_state *state, gimple tp) gimple_try_set_cleanup (tp, new_seq); - return frob_into_branch_around (tp, try_region, out_label); + gimple_seq new_eh_seq = eh_seq; + eh_seq = old_eh_seq; + gimple_seq ret_seq = frob_into_branch_around (tp, try_region, out_label); + gimple_seq_add_seq (&eh_seq, new_eh_seq); + return ret_seq; } /* A subroutine of lower_eh_constructs_1. Lower a GIMPLE_TRY with a