* [PATCH] Wrong coverage attribution.
@ 2007-07-26 23:35 Seongbae Park (박성배, 朴成培)
2007-07-30 18:34 ` Seongbae Park (박성배, 朴成培)
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Seongbae Park (박성배, 朴成培) @ 2007-07-26 23:35 UTC (permalink / raw)
To: gcc-patches, Janis Johnson, mark, nathan
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]
Hi,
gcc/ChangeLog:
2007-07-26 Seongbae Park <seongbae.park@gmail.com>
* tree-eh.c (lower_try_finally_onedest): Reset the locus of moved goto.
gcc/testsuite/ChangeLog:
2007-07-26 Seongbae Park <seongbae.park@gmail.com>
* lib/gcov.exp (verify-lines): Recognize - and # as possible count.
* g++.dg/gcov/gcov-4.C: New test.
Attached patch fixes the problem shown in the testcase
- this testcase fails in the current mainline
because of GOTO moved to a different block during eh lowering.
Bootstrap and regtest are in progress.
If all tests look clean,
ok for mainline and 4.2 branch ?
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
[-- Attachment #2: bad-eh-lineno.patch --]
[-- Type: text/x-patch, Size: 2342 bytes --]
Index: gcc/testsuite/g++.dg/gcov/gcov-4.C
===================================================================
--- gcc/testsuite/g++.dg/gcov/gcov-4.C (revision 0)
+++ gcc/testsuite/g++.dg/gcov/gcov-4.C (revision 0)
@@ -0,0 +1,41 @@
+/* Check that execution counts and branch probabilities for various C
+ constructs are reported correctly by gcov. */
+
+#include <stdio.h>
+
+/* { dg-options "-fprofile-arcs -ftest-coverage -fno-exceptions" } */
+/* { dg-do run { target native } } */
+
+class foo {
+public:
+ foo() { printf("foo()\n"); };
+ ~foo() { printf("~foo()\n"); };
+ void method(void) { printf("method()\n"); };
+};
+
+int func(int i, int j) __attribute__((noinline));
+
+int func(int i, int j){
+ if (j) {
+ printf("unreachable\n");
+ return 3;
+ }
+
+ foo f;
+
+ if (i == 1) {
+ f.method();
+ f.method();
+ } else {
+ f.method();
+ printf("unreachable\n");
+ return 2; /* count(#####) */
+ }
+ f.method();
+ return 0;
+}
+
+int main() {
+ return func(1, 0);
+}
+/* { dg-final { run-gcov gcov-4.C } } */
Index: gcc/testsuite/lib/gcov.exp
===================================================================
--- gcc/testsuite/lib/gcov.exp (revision 126963)
+++ gcc/testsuite/lib/gcov.exp (working copy)
@@ -42,7 +42,9 @@ proc verify-lines { testcase file } {
set failed 0
set fd [open $file r]
while { [gets $fd line] >= 0 } {
- if [regexp "^ *(\[^:]*): *(\[0-9\]+):.*count\\((\[0-9\]+)\\)" \
+ # We want to match both "-" and "#####" as count as well as numbers,
+ # since we want to detect lines that shouldn't be marked as covered.
+ if [regexp "^ *(\[^:]*): *(\[0-9\\-#]+):.*count\\((\[0-9\\-#]+)\\)" \
"$line" all is n shouldbe] {
if { $is == "" } {
fail "$n:no data available for this line"
Index: gcc/tree-eh.c
===================================================================
--- gcc/tree-eh.c (revision 126963)
+++ gcc/tree-eh.c (working copy)
@@ -999,6 +999,9 @@ lower_try_finally_onedest (struct leh_st
}
}
+ /* Reset the locus of the goto since we're moving
+ goto to a different block which might be on a different line. */
+ SET_EXPR_LOCUS (tf->goto_queue[0].cont_stmt, NULL);
append_to_statement_list (tf->goto_queue[0].cont_stmt, tf->top_p);
maybe_record_in_goto_queue (state, tf->goto_queue[0].cont_stmt);
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-07-26 23:35 [PATCH] Wrong coverage attribution Seongbae Park (박성배, 朴成培)
@ 2007-07-30 18:34 ` Seongbae Park (박성배, 朴成培)
2007-07-31 3:52 ` Nathan Sidwell
2007-08-09 4:41 ` Seongbae Park (박성배, 朴成培)
2007-07-30 19:12 ` Janis Johnson
2007-08-16 1:35 ` Diego Novillo
2 siblings, 2 replies; 10+ messages in thread
From: Seongbae Park (박성배, 朴成培) @ 2007-07-30 18:34 UTC (permalink / raw)
To: gcc-patches, Janis Johnson, mark, nathan
*ping*
On 7/26/07, Seongbae Park (박성배, 朴成培) <seongbae.park@gmail.com> wrote:
> Hi,
>
> gcc/ChangeLog:
> 2007-07-26 Seongbae Park <seongbae.park@gmail.com>
>
> * tree-eh.c (lower_try_finally_onedest): Reset the locus of moved goto.
>
> gcc/testsuite/ChangeLog:
> 2007-07-26 Seongbae Park <seongbae.park@gmail.com>
>
> * lib/gcov.exp (verify-lines): Recognize - and # as possible count.
> * g++.dg/gcov/gcov-4.C: New test.
>
>
> Attached patch fixes the problem shown in the testcase
> - this testcase fails in the current mainline
> because of GOTO moved to a different block during eh lowering.
>
> Bootstrap and regtest are in progress.
> If all tests look clean,
> ok for mainline and 4.2 branch ?
> --
> #pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
>
>
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-07-30 18:34 ` Seongbae Park (박성배, 朴成培)
@ 2007-07-31 3:52 ` Nathan Sidwell
2007-07-31 15:44 ` Seongbae Park (박성배, 朴成培)
2007-08-09 4:41 ` Seongbae Park (박성배, 朴成培)
1 sibling, 1 reply; 10+ messages in thread
From: Nathan Sidwell @ 2007-07-31 3:52 UTC (permalink / raw)
To: "Seongbae Park (???, ???)"; +Cc: gcc-patches, Janis Johnson, mark
Seongbae Park (???, ???) wrote:
> *ping*
>> Attached patch fixes the problem shown in the testcase
>> - this testcase fails in the current mainline
>> because of GOTO moved to a different block during eh lowering.
Sorry, I thought I'd emailed you about this, but I find no record of that.
Could you explain in more detail what the problem is and why your patch is correct?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-07-31 3:52 ` Nathan Sidwell
@ 2007-07-31 15:44 ` Seongbae Park (박성배, 朴成培)
2007-07-31 18:20 ` Seongbae Park (박성배, 朴成培)
0 siblings, 1 reply; 10+ messages in thread
From: Seongbae Park (박성배, 朴成培) @ 2007-07-31 15:44 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: gcc-patches, Janis Johnson, mark
On 7/30/07, Nathan Sidwell <nathan@codesourcery.com> wrote:
> Seongbae Park (???, ???) wrote:
> > *ping*
>
> >> Attached patch fixes the problem shown in the testcase
> >> - this testcase fails in the current mainline
> >> because of GOTO moved to a different block during eh lowering.
>
> Sorry, I thought I'd emailed you about this, but I find no record of that.
> Could you explain in more detail what the problem is and why your patch is correct?
Sure.
Given the new testcase included in the patch:
26 if (i == 1) {
27 f.method();
28 f.method();
29 } else {
30 f.method();
31 printf("unreachable\n");
32 return 2; /* count(#####) */
33 }
34 f.method();
35 return 0;
36 }
we get the following tree at the end of lowering (and before tree-eh):
[gcov-4.C : 35] try
{
[gcov-4.C : 26] if (i == 1) goto <D2786>; else goto <D2787>;
<D2786>:;
[gcov-4.C : 27] method (&f);
[gcov-4.C : 28] method (&f);
goto <D2788>;
<D2787>:;
[gcov-4.C : 30] method (&f);
[gcov-4.C : 31] __builtin_puts (&"unreachable"[0]);
[gcov-4.C : 32] D.2776 = 2;
[gcov-4.C : 32] goto <D2783>;
<D2788>:;
[gcov-4.C : 34] method (&f);
[gcov-4.C : 35] D.2776 = 0;
[gcov-4.C : 35] goto <D2783>;
}
finally
{
[gcov-4.C : 35] __comp_dtor (&f);
}
<D2783>:;
return D.2776;
After tree-eh (with the patch, without patch,
GOTO D2783 in block D2789 would have the line no 32):
[gcov-4.C : 26] if (i == 1) goto <D2786>; else goto <D2787>;
<D2786>:;
[gcov-4.C : 27] method (&f);
[gcov-4.C : 28] method (&f);
goto <D2788>;
<D2787>:;
[gcov-4.C : 30] method (&f);
[gcov-4.C : 31] __builtin_puts (&"unreachable"[0]);
[gcov-4.C : 32] D.2776 = 2;
goto <D2789>;
<D2788>:;
[gcov-4.C : 34] method (&f);
[gcov-4.C : 35] D.2776 = 0;
goto <D2789>;
<D2789>:;
[gcov-4.C : 35] __comp_dtor (&f);
goto <D2783>;
<D2783>:;
return D.2776;
lower_try_finally_onedest() is called only when try-finally
has only one destination for the finally.
During lower_try_finally_onedest(), among all collected goto's
to the common destination of finally,
we arbitrarily pick the first GOTO and append it to the finally block.
Obviously, the original GOTO for line 32 doesn't belong to the finally block,
hence the fix.
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-07-31 15:44 ` Seongbae Park (박성배, 朴成培)
@ 2007-07-31 18:20 ` Seongbae Park (박성배, 朴成培)
0 siblings, 0 replies; 10+ messages in thread
From: Seongbae Park (박성배, 朴成培) @ 2007-07-31 18:20 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: gcc-patches, Janis Johnson, mark
On 7/31/07, Seongbae Park (박성배, 朴成培) <seongbae.park@gmail.com> wrote:
> On 7/30/07, Nathan Sidwell <nathan@codesourcery.com> wrote:
> > Seongbae Park (???, ???) wrote:
> > > *ping*
> >
> > >> Attached patch fixes the problem shown in the testcase
> > >> - this testcase fails in the current mainline
> > >> because of GOTO moved to a different block during eh lowering.
> >
> > Sorry, I thought I'd emailed you about this, but I find no record of that.
> > Could you explain in more detail what the problem is and why your patch is correct?
>
> Sure.
>
> Given the new testcase included in the patch:
>
> 26 if (i == 1) {
> 27 f.method();
> 28 f.method();
> 29 } else {
> 30 f.method();
> 31 printf("unreachable\n");
> 32 return 2; /* count(#####) */
> 33 }
> 34 f.method();
> 35 return 0;
> 36 }
>
> we get the following tree at the end of lowering (and before tree-eh):
>
> [gcov-4.C : 35] try
> {
> [gcov-4.C : 26] if (i == 1) goto <D2786>; else goto <D2787>;
> <D2786>:;
> [gcov-4.C : 27] method (&f);
> [gcov-4.C : 28] method (&f);
> goto <D2788>;
> <D2787>:;
> [gcov-4.C : 30] method (&f);
> [gcov-4.C : 31] __builtin_puts (&"unreachable"[0]);
> [gcov-4.C : 32] D.2776 = 2;
> [gcov-4.C : 32] goto <D2783>;
> <D2788>:;
> [gcov-4.C : 34] method (&f);
> [gcov-4.C : 35] D.2776 = 0;
> [gcov-4.C : 35] goto <D2783>;
> }
> finally
> {
> [gcov-4.C : 35] __comp_dtor (&f);
> }
> <D2783>:;
> return D.2776;
>
> After tree-eh (with the patch, without patch,
> GOTO D2783 in block D2789 would have the line no 32):
>
> [gcov-4.C : 26] if (i == 1) goto <D2786>; else goto <D2787>;
> <D2786>:;
> [gcov-4.C : 27] method (&f);
> [gcov-4.C : 28] method (&f);
> goto <D2788>;
> <D2787>:;
> [gcov-4.C : 30] method (&f);
> [gcov-4.C : 31] __builtin_puts (&"unreachable"[0]);
> [gcov-4.C : 32] D.2776 = 2;
> goto <D2789>;
> <D2788>:;
> [gcov-4.C : 34] method (&f);
> [gcov-4.C : 35] D.2776 = 0;
> goto <D2789>;
> <D2789>:;
> [gcov-4.C : 35] __comp_dtor (&f);
> goto <D2783>;
> <D2783>:;
> return D.2776;
I just realized that I haven't explained things in enough detail:
> lower_try_finally_onedest() is called only when try-finally
> has only one destination for the finally.
> During lower_try_finally_onedest(), among all collected goto's
> to the common destination of finally,
> we arbitrarily pick the first GOTO and append it to the finally block.
By the first goto, I meant
[gcov-4.C : 32] goto <D2783>;
in block D2787 before tree-eh. This GOTO and all other
GOTOs that go to D2783 within try region are removed by
do_goto_redirection() call within lower_try_finally_onedest(),
and then the first one among removed GOTOs is append
to the end of the finally block.
> Obviously, the original GOTO for line 32 doesn't belong to the finally block,
> hence the fix.
Without the fix, because the problematic GOTO is now moved to
the end of the finally block, it gets executed always,
unlike the original GOTO. This gives us the wrong coverage result
because the line that GOTO belongs to shouldn't be shown as executed.
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-07-30 18:34 ` Seongbae Park (박성배, 朴成培)
2007-07-31 3:52 ` Nathan Sidwell
@ 2007-08-09 4:41 ` Seongbae Park (박성배, 朴成培)
2007-08-15 23:12 ` Seongbae Park (박성배, 朴成培)
1 sibling, 1 reply; 10+ messages in thread
From: Seongbae Park (박성배, 朴成培) @ 2007-08-09 4:41 UTC (permalink / raw)
To: gcc-patches, Janis Johnson, mark, nathan
*ping^2*
FYI, this pending patch is holding my other approved patch:
http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00366.html
Seongbae
On 7/30/07, Seongbae Park (박성배, 朴成培) <seongbae.park@gmail.com> wrote:
> *ping*
>
> On 7/26/07, Seongbae Park (박성배, 朴成培) <seongbae.park@gmail.com> wrote:
> > Hi,
> >
> > gcc/ChangeLog:
> > 2007-07-26 Seongbae Park <seongbae.park@gmail.com>
> >
> > * tree-eh.c (lower_try_finally_onedest): Reset the locus of moved goto.
> >
> > gcc/testsuite/ChangeLog:
> > 2007-07-26 Seongbae Park <seongbae.park@gmail.com>
> >
> > * lib/gcov.exp (verify-lines): Recognize - and # as possible count.
> > * g++.dg/gcov/gcov-4.C: New test.
> >
> >
> > Attached patch fixes the problem shown in the testcase
> > - this testcase fails in the current mainline
> > because of GOTO moved to a different block during eh lowering.
> >
> > Bootstrap and regtest are in progress.
> > If all tests look clean,
> > ok for mainline and 4.2 branch ?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-08-09 4:41 ` Seongbae Park (박성배, 朴成培)
@ 2007-08-15 23:12 ` Seongbae Park (박성배, 朴成培)
0 siblings, 0 replies; 10+ messages in thread
From: Seongbae Park (박성배, 朴成培) @ 2007-08-15 23:12 UTC (permalink / raw)
To: gcc-patches, Janis Johnson, mark, nathan
*ping*^3
Seongbae
On 8/8/07, Seongbae Park (박성배, 朴成培) <seongbae.park@gmail.com> wrote:
> *ping^2*
>
> FYI, this pending patch is holding my other approved patch:
>
> http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00366.html
>
> Seongbae
>
> On 7/30/07, Seongbae Park (박성배, 朴成培) <seongbae.park@gmail.com> wrote:
> > *ping*
> >
> > On 7/26/07, Seongbae Park (박성배, 朴成培) <seongbae.park@gmail.com> wrote:
> > > Hi,
> > >
> > > gcc/ChangeLog:
> > > 2007-07-26 Seongbae Park <seongbae.park@gmail.com>
> > >
> > > * tree-eh.c (lower_try_finally_onedest): Reset the locus of moved goto.
> > >
> > > gcc/testsuite/ChangeLog:
> > > 2007-07-26 Seongbae Park <seongbae.park@gmail.com>
> > >
> > > * lib/gcov.exp (verify-lines): Recognize - and # as possible count.
> > > * g++.dg/gcov/gcov-4.C: New test.
> > >
> > >
> > > Attached patch fixes the problem shown in the testcase
> > > - this testcase fails in the current mainline
> > > because of GOTO moved to a different block during eh lowering.
> > >
> > > Bootstrap and regtest are in progress.
> > > If all tests look clean,
> > > ok for mainline and 4.2 branch ?
>
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-07-26 23:35 [PATCH] Wrong coverage attribution Seongbae Park (박성배, 朴成培)
2007-07-30 18:34 ` Seongbae Park (박성배, 朴成培)
@ 2007-07-30 19:12 ` Janis Johnson
2007-08-16 1:35 ` Diego Novillo
2 siblings, 0 replies; 10+ messages in thread
From: Janis Johnson @ 2007-07-30 19:12 UTC (permalink / raw)
To: Seongbae Park (박성배, 朴成培)
Cc: gcc-patches, mark, nathan
On Thu, 2007-07-26 at 16:09 -0700, Seongbae Park (ë°ì±ë°°, æ´æå¹) wrote:
> Hi,
>
> gcc/ChangeLog:
> 2007-07-26 Seongbae Park <seongbae.park@gmail.com>
>
> * tree-eh.c (lower_try_finally_onedest): Reset the locus of moved goto.
>
> gcc/testsuite/ChangeLog:
> 2007-07-26 Seongbae Park <seongbae.park@gmail.com>
>
> * lib/gcov.exp (verify-lines): Recognize - and # as possible count.
> * g++.dg/gcov/gcov-4.C: New test.
The testsuite parts are OK.
Janis
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-07-26 23:35 [PATCH] Wrong coverage attribution Seongbae Park (박성배, 朴成培)
2007-07-30 18:34 ` Seongbae Park (박성배, 朴成培)
2007-07-30 19:12 ` Janis Johnson
@ 2007-08-16 1:35 ` Diego Novillo
2007-08-16 17:30 ` Seongbae Park (박성배, 朴成培)
2 siblings, 1 reply; 10+ messages in thread
From: Diego Novillo @ 2007-08-16 1:35 UTC (permalink / raw)
To: "Seongbae Park (¹Ú¼º¹è,
ÚÓà÷ÛÆ)"
Cc: gcc-patches, Janis Johnson, mark, nathan
On 7/26/07 7:09 PM, Seongbae Park (¹Ã¼º¹è, ÃÃà ÷ÃÃ) wrote:
> * tree-eh.c (lower_try_finally_onedest): Reset the locus of moved goto.
OK.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Wrong coverage attribution.
2007-08-16 1:35 ` Diego Novillo
@ 2007-08-16 17:30 ` Seongbae Park (박성배, 朴成培)
0 siblings, 0 replies; 10+ messages in thread
From: Seongbae Park (박성배, 朴成培) @ 2007-08-16 17:30 UTC (permalink / raw)
To: Diego Novillo; +Cc: gcc-patches, Janis Johnson, mark, nathan
On 8/15/07, Diego Novillo <dnovillo@google.com> wrote:
> On 7/26/07 7:09 PM, Seongbae Park (¹Ú¼º¹è, ÚÓà÷ÛÆ) wrote:
>
> > * tree-eh.c (lower_try_finally_onedest): Reset the locus of moved goto.
>
>
> OK.
Thanks. Commited as 127562.
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-08-16 17:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 23:35 [PATCH] Wrong coverage attribution Seongbae Park (박성배, 朴成培)
2007-07-30 18:34 ` Seongbae Park (박성배, 朴成培)
2007-07-31 3:52 ` Nathan Sidwell
2007-07-31 15:44 ` Seongbae Park (박성배, 朴成培)
2007-07-31 18:20 ` Seongbae Park (박성배, 朴成培)
2007-08-09 4:41 ` Seongbae Park (박성배, 朴成培)
2007-08-15 23:12 ` Seongbae Park (박성배, 朴成培)
2007-07-30 19:12 ` Janis Johnson
2007-08-16 1:35 ` Diego Novillo
2007-08-16 17:30 ` Seongbae Park (박성배, 朴成培)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).