On 02/18/15 11:40, Jakub Jelinek wrote:
Hi!
Richard's GIMPLE EH rewrite in r151696 regressed following testcase.
The problem is that when lowering:
[gcov-15.C:14:5] try
{
[gcov-15.C:18:12] D.2335 = __cxa_allocate_exception (4);
[gcov-15.C:18:12] try
{
[gcov-15.C:18:12] [gcov-15.C:18:12] MEM[(int *)D.2335] = 5;
}
catch
{
[gcov-15.C:18:11] __cxa_free_exception (D.2335);
}
[gcov-15.C:18:11] __cxa_throw (D.2335, &_ZTIi, 0B);
}
catch
{
[gcov-15.C:20:3] catch (NULL)
{
[gcov-15.C:20:3] try
{
[gcov-15.C:20:10] D.2340 = __builtin_eh_pointer (0);
[gcov-15.C:20:10] __cxa_begin_catch (D.2340);
[gcov-15.C:22:15] catchEx ();
}
finally
{
[gcov-15.C:20:10] __cxa_end_catch ();
}
}
}
we put the cleanup of the catch cleanup in front of the catch cleanup
in the EH sequence:
[gcov-15.C:18:12] D.2335 = __cxa_allocate_exception (4);
[gcov-15.C:18:12] [gcov-15.C:18:12] MEM[(int *)D.2335] = 5;
[gcov-15.C:18:11] __cxa_throw (D.2335, &_ZTIi, 0B);
<D.2345>:
[gcov-15.C:24:1] D.2341 = 0;
[gcov-15.C:24:1] goto <D.2342>;
<D.2342>:
[gcov-15.C:24:1] return D.2341;
<D.2343>:
[gcov-15.C:20:10] __cxa_end_catch ();
resx 3
<D.2346>:
eh_dispatch 1
resx 1
<D.2344>:
[gcov-15.C:20:10] D.2340 = __builtin_eh_pointer (1);
[gcov-15.C:20:10] __cxa_begin_catch (D.2340);
[gcov-15.C:22:15] catchEx ();
[gcov-15.C:20:10] __cxa_end_catch ();
goto <D.2345>;
and as the __cxa_end_catch () is the first bb for line 20,
gcov without -a considers that bb count as the one to be shown.
Before the gimple EH rewrite and also with this patch we instead
order the cleanup (__cxa_end_catch ()) after the __cxa_begin_catch ():
[gcov-15.C:18:12] D.2335 = __cxa_allocate_exception (4);
[gcov-15.C:18:12] [gcov-15.C:18:12] MEM[(int *)D.2335] = 5;
[gcov-15.C:18:11] __cxa_throw (D.2335, &_ZTIi, 0B);
<D.2345>:
[gcov-15.C:24:1] D.2341 = 0;
[gcov-15.C:24:1] goto <D.2342>;
<D.2342>:
[gcov-15.C:24:1] return D.2341;
<D.2346>:
eh_dispatch 1
resx 1
<D.2344>:
[gcov-15.C:20:10] D.2340 = __builtin_eh_pointer (1);
[gcov-15.C:20:10] __cxa_begin_catch (D.2340);
[gcov-15.C:22:15] catchEx ();
[gcov-15.C:20:10] __cxa_end_catch ();
goto <D.2345>;
<D.2343>:
[gcov-15.C:20:10] __cxa_end_catch ();
resx 3
Bootstrapped/regtested on x86_64-linux and i686-linux,
libstdc++.so.6 compiled without and with the patch is identical on
x86_64-linux. The testcase also has identical generated code both at -O0
and -O2 when compiled without coverage. Ok for trunk?
2015-02-18 Jakub Jelinek <ja...@redhat.com>
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.
OK.
jeff