From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 9BF0D385734F for ; Tue, 11 Oct 2022 12:43:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9BF0D385734F Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=woven-planet.global Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=woven-planet.global Received: by mail-lf1-x134.google.com with SMTP id bp15so20887835lfb.13 for ; Tue, 11 Oct 2022 05:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=woven-planet.global; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TVHCy6IPVMGEVNqEXeBpUyxooH63sHQGttlWDQ0hwlY=; b=Kdke43EMxNIlTZA45mmZ8iQABWja8cGgQIx0aW91ySrM7zt0OnVzjKji7+E403a5Yz FBe0FRLVauHvhC5sL2T9zSA/GgccM8ZmaaZ4gc1YwrAUN79Hs8W7jcYBBDyOfk53zMRs fRSxx9gQqt3RszW32UPeLClWw2w6yFojAHQPo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TVHCy6IPVMGEVNqEXeBpUyxooH63sHQGttlWDQ0hwlY=; b=T5WKszCVT0DT7MDu4QwyfDXlzXQjvQsvFKGexV/yjmFbX1uFj04yQ2XmoTjwPn3YxE fg56/FrcmGmF4SJi5T3Y3o2rlyT+c4LmhA+6VllyjWvNV7YEqZNmYSQOwMGegbKrtIZJ JTvrCzXpTZ6l0JTtaHu9iKU5q9eIUOaUaCYMNq1nDMCrTGNxrwv/Lhzk6MZNi2Z/y/gR 5i6PH1wszEf1fe9gJKjFa64D/00uUJ7QxdDtQdIXDyWWyCxFllhaYmVgftjj42+kqYHv mLncnzvJx6KZpLwSdBd3lBm7DgXX1SsZSLv1E/0V/29kV5FJgdsWNF5zdBzCw3cLmdkC 4DyA== X-Gm-Message-State: ACrzQf030wY6IIx12W06hUqMGF+7eUw1YlNLrhSBR47ciKlnf2AucBos T3UWKzbYk6BAqq0zWvGAw4WiOdL0U3/5GkPsvEbSdfauioOtudvfJdhn3HJUz2Oyhd3MvqteBgs cr8/B/Iksupvn4oEEUi3jEG/RhsMLEPHjovpHwRW1mbsdazzhN8Ro5gLT4ZI78nhkpy8AzQtB+b 7Htbc7XBaP9boPEy9LUtE= X-Google-Smtp-Source: AMsMyM6AW9R6aInzJp6/KpbPJ1/+0C+iKWyDuw5K7cIgEFopqyTcyVGrzqAJFW229DHs4CmQXLQOww== X-Received: by 2002:ac2:5e9d:0:b0:4a0:5828:6cf8 with SMTP id b29-20020ac25e9d000000b004a058286cf8mr7916495lfq.567.1665492197115; Tue, 11 Oct 2022 05:43:17 -0700 (PDT) Received: from localhost.localdomain ([2a02:2121:6ca:a542:1c10:1c18:418e:cd9d]) by smtp.gmail.com with ESMTPSA id p9-20020a2eb7c9000000b00262fae1ffe6sm2131060ljo.110.2022.10.11.05.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 05:43:15 -0700 (PDT) From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, mliska@suse.cz, =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Subject: [PATCH 1/2] gcov: test switch/break line counts Date: Tue, 11 Oct 2022 14:43:02 +0200 Message-Id: <20221011124303.99673-1-jorgen.kvalsvik@woven-planet.global> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,TXREP,T_SPF_PERMERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- 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) */ -- 2.34.0