From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7901) id BE4653858C56; Fri, 14 Oct 2022 08:49:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE4653858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665737387; bh=gs7og+q17Mti21CTw138lXAtJcHP2HSQ2qujFyudCic=; h=From:To:Subject:Date:From; b=LWTqr2V9g/mQ9Vy9VYcqv0PX3dbAfl+Ji3IGHuZ4GAGj405251q/D+xNoIZhunC4+ 5m5IBMS++M310w6rXNwvz9rerDzCL6sbcGUStV5a2VdXR186rtQriTf6FXd0L6j/U/ ZTpR2ibuQDJisCpxhcP0E+25v5Wk6osWeWkWWkl8= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: =?iso-8859-1?q?J=F8rgen_Kvalsvik?= To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3293] gcov: test switch/break line counts X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= X-Git-Refname: refs/heads/master X-Git-Oldrev: c2565a31c1622ab0926aeef4a6579413e121b9f9 X-Git-Newrev: 4b04292b76e89b332ae70208aabf8f0e12f3a63f Message-Id: <20221014084947.BE4653858C56@sourceware.org> Date: Fri, 14 Oct 2022 08:49:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4b04292b76e89b332ae70208aabf8f0e12f3a63f commit r13-3293-g4b04292b76e89b332ae70208aabf8f0e12f3a63f Author: Jørgen Kvalsvik Date: Tue Oct 4 15:45:59 2022 +0200 gcov: test switch/break line counts The coverage support will under some conditions decide to split edges to accurately report coverage. By running the test suite with/without this edge splitting a small diff shows up, addressed by this patch, which should catch future regressions. Removing the edge splitting: $ diff --git a/gcc/profile.cc b/gcc/profile.cc --- a/gcc/profile.cc +++ b/gcc/profile.cc @@ -1244,19 +1244,7 @@ branch_prob (bool thunk) Don't do that when the locuses match, so if (blah) goto something; is not computed twice. */ - if (last - && gimple_has_location (last) - && !RESERVED_LOCATION_P (e->goto_locus) - && !single_succ_p (bb) - && (LOCATION_FILE (e->goto_locus) - != LOCATION_FILE (gimple_location (last)) - || (LOCATION_LINE (e->goto_locus) - != LOCATION_LINE (gimple_location (last))))) - { - basic_block new_bb = split_edge (e); - edge ne = single_succ_edge (new_bb); - ne->goto_locus = e->goto_locus; - } + if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL)) && e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun)) need_exit_edge = 1; Assuming the .gcov files from make chec-gcc RUNTESTFLAGS=gcov.exp are kept: $ diff -r no-split-edge with-split-edge | grep -C 2 -E "^[<>]\s\s" diff -r sans-split-edge/gcc/gcov-4.c.gcov with-split-edge/gcc/gcov-4.c.gcov 228c228 < -: 224: break; --- > 1: 224: break; 231c231 < -: 227: break; --- > #####: 227: break; 237c237 < -: 233: break; --- > 2: 233: break; gcc/testsuite/ChangeLog: * g++.dg/gcov/gcov-1.C: Add line count check. * gcc.misc-tests/gcov-4.c: Likewise. Diff: --- gcc/testsuite/g++.dg/gcov/gcov-1.C | 8 ++++---- gcc/testsuite/gcc.misc-tests/gcov-4.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/g++.dg/gcov/gcov-1.C b/gcc/testsuite/g++.dg/gcov/gcov-1.C index 9018b9a3a73..ee383b480a8 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-1.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-1.C @@ -257,20 +257,20 @@ test_switch (int i, int j) switch (i) /* count(5) */ /* branch(end) */ { - case 1: + case 1: /* count(1) */ result = do_something (2); /* count(1) */ - break; + break; /* count(1) */ case 2: result = do_something (1024); break; - case 3: + case 3: /* count(3) */ case 4: /* branch(67) */ if (j == 2) /* count(3) */ /* branch(end) */ return do_something (4); /* count(1) */ result = do_something (8); /* count(2) */ - break; + break; /* count(2) */ default: result = do_something (32); /* count(1) */ switch_m++; /* count(1) */ diff --git a/gcc/testsuite/gcc.misc-tests/gcov-4.c b/gcc/testsuite/gcc.misc-tests/gcov-4.c index 9d8ab1c1097..498d299b66b 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov-4.c +++ b/gcc/testsuite/gcc.misc-tests/gcov-4.c @@ -221,7 +221,7 @@ test_switch (int i, int j) { case 1: result = do_something (2); /* count(1) */ - break; + break; /* count(1) */ case 2: result = do_something (1024); break; @@ -230,7 +230,7 @@ test_switch (int i, int j) if (j == 2) /* count(3) */ return do_something (4); /* count(1) */ result = do_something (8); /* count(2) */ - break; + break; /* count(2) */ default: result = do_something (32); /* count(1) */ switch_m++; /* count(1) */