From patchwork Fri Apr 5 19:58:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= X-Patchwork-Id: 1920343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (4096-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.a=rsa-sha256 header.s=dkim20160331 header.b=V9hAeDuB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VB8TY6Zj1z1yYy for ; Sat, 6 Apr 2024 06:59:45 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 24ABF38460A2 for ; Fri, 5 Apr 2024 19:59:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.154]) by sourceware.org (Postfix) with ESMTPS id BD0A43858D34 for ; Fri, 5 Apr 2024 19:58:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD0A43858D34 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lambda.is Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lambda.is ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BD0A43858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.103.80.154 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712347138; cv=none; b=e0WUJIkGGKHcSgIyyT8gemZxl9w1m2hpWb9Q0nSrhZ/fbM4C+pbd01pUqo1rRKTInA/DrWx3RfpVuW6Aefp4cSB+3vB3m8j0Z1p8nahBBxIic4OnOHI057D5Nvn+ERGTxpZLcAMFymNhoTBUSWsE8DbhXNTj4huM/gsrr9Yzxt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712347138; c=relaxed/simple; bh=RyqI5PGva+WGmiHpCjw6Q6AJJ+qVTvsSpMarL0CAtc4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=BoC5QJbFVp+7WSlMWI+bt6zHtxSuaPIUvZXSqpiAr7MrMiHLrZthgYs0+dDeZzdOAq5793Xz5Iyno7z+BXUhGOBpkqC+bkTantgFWrAp6VMxTKqmJNjJS4dSzXsTOCfqhrY9uEr3rj1KTxBOX5wH0GkXQVuJoDEXb+Ulg5RPKoI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 938B530D84AE; Fri, 5 Apr 2024 21:58:55 +0200 (CEST) Authentication-Results: ext-mx-out013.mykolab.com (amavis); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20160331; t=1712347134; x=1714161535; bh=KNxEWq+G1u8OC9kLue9JcdpfvDDIu7PFmvSF9SVTyss=; b=V9hAeDuB/1W4 gzTXMZv9US0hlwjLxxfCVevQsK8STpsG19Fdybcb9T9B+U6wxigItzuiqrBnK9vo 6eZLQlFidPdfeiiYSo2LfN9WwhRQyOwOm0PCpnvSZ9EPJtUSxqEQ4zfxQRl9iX91 ZjIkANm0bGDQ3CiL64Q0ALMKKXjN9vFiVbb9iLbVoKmKoq7o++H5rLv9Y0PRlvRq GyAqBthIZDb6NYRLGwh4oexwjqShZ91GhPDqLYZVXg0xS/jymqQgVjUaAAnxVMrQ Mu6caSYvQYVu2wQsLp/ClNIGtUFEXvowElsDTZwU3a0p+VpkA8s+P2G5V/Bhjlvj p8hUYvlPEHMlmCDHl/3JbCAXhyuHyOQcgW8xo9uaFyHp1X5l9TcRh7MADnEjGrkL 3Ubja6qcIwM8dMmaBuGqq/6j6KYCvgW8JrB9o+3hYeqSelM/+Yo8j5OC0RSJRcOQ Usho2ZHlnFlFzsnbJExqljBPFQPpq7ezedlM7Yc515SOpNikiHlD/OVuSTgHndB9 I+gJln1PpfJbtHrZU/foDRIWR5XLXtM6aIh3BKqQevIMiQskR1hYTxUrj7pR0G6W NmwxdBYqjyIpAoE1MZsBea5Z814cPcKQFybD6x/NA6wQD/YnM2FqmZ/uBgobQK0m dJxwFCnL3qoKixaqT0egRKxkoafMLwI= X-Virus-Scanned: amavis at mykolab.com X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out013.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id Wz4vqMbDeamk; Fri, 5 Apr 2024 21:58:54 +0200 (CEST) Received: from int-mx011.mykolab.com (unknown [10.9.13.11]) by mx.kolabnow.com (Postfix) with ESMTPS id A09D43085BC5; Fri, 5 Apr 2024 21:58:54 +0200 (CEST) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx011.mykolab.com (Postfix) with ESMTPS id 593D030FB470; Fri, 5 Apr 2024 21:58:54 +0200 (CEST) From: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= To: gcc-patches@gcc.gnu.org Cc: hjl.tools@gmail.com, rguenther@suse.de, hubicka@ucw.cz, ro@CeBiTec.Uni-Bielefeld.DE, =?utf-8?q?J=C3=B8rgen_Kvalsvik?= Subject: [PATCH 1/2] Remove unecessary and broken MC/DC compile test Date: Fri, 5 Apr 2024 21:58:30 +0200 Message-Id: <20240405195831.2728853-2-j@lambda.is> In-Reply-To: <20240405195831.2728853-1-j@lambda.is> References: <20240405195831.2728853-1-j@lambda.is> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org The __sigsetjmp test was added as a regression test, which an early iteration of the MC/DC support caused an internal compiler error, triggered by a code path which did not make it through to the final revision. Since this test really only worked on linux and does not serve a purpose any more it can be removed. gcc/testsuite/ChangeLog: * gcc.misc-tests/gcov-19.c: Remove test. --- gcc/testsuite/gcc.misc-tests/gcov-19.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/gcc/testsuite/gcc.misc-tests/gcov-19.c b/gcc/testsuite/gcc.misc-tests/gcov-19.c index 17f1fb4e923..b83a38531ba 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov-19.c +++ b/gcc/testsuite/gcc.misc-tests/gcov-19.c @@ -869,17 +869,6 @@ dest: goto * 0; } -int __sigsetjmp (); - -/* This should compile, but not called. */ -void -mcdc021c () -{ - while (x) /* conditions(0/2) true(0) false(0)*/ - /* conditions(end) */ - __sigsetjmp (); -} - /* If edges are not properly contracted the a && id (b) will be interpreted as two independent expressions. */ void From patchwork Fri Apr 5 19:58:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= X-Patchwork-Id: 1920342 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (4096-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.a=rsa-sha256 header.s=dkim20160331 header.b=XiOn/+yG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VB8TF2vrXz1yYy for ; Sat, 6 Apr 2024 06:59:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 972FD3844752 for ; Fri, 5 Apr 2024 19:59:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.155]) by sourceware.org (Postfix) with ESMTPS id 257CD384641E for ; Fri, 5 Apr 2024 19:58:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 257CD384641E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lambda.is Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lambda.is ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 257CD384641E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.103.80.155 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712347142; cv=none; b=I3QrXFR996yLSOpO0S4pYRc/lRSCZLQDwHPBg2emF7FTKWaFZ9t+GSNWmEWGBmaRHFaRSFSV7MrDtZtsluSQ5wn/ANTf517kIiPSrX6DkVNt+QlCbdsgWdswuPpFlaaEkDZvEER1m9jtJA8WGgVLirqUoKjFNq7FoIuXB/ulTCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712347142; c=relaxed/simple; bh=YVYT+wlhm/7OWYvuMHuxUMykiLInaTkNBxQ1WW2Bojo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=I6Suk25S6NXu/K1/BfPUUgOUWylC87YVfWpWn+28I1eG9gUUMAfe3fxp3nlxGmV41hjbp0AWZUC8wJS0eAFqRICamr+sEgUvjwDXr1hTlRmccTMgyGVHRuIDTVBxcaPNJURzPCqNAnMDMbDB+kp9b4DV+qbR4l3yBa/N5BSgtaw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 4CDAB2096DD0; Fri, 5 Apr 2024 21:58:58 +0200 (CEST) Authentication-Results: ext-mx-out011.mykolab.com (amavis); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20160331; t=1712347137; x=1714161538; bh=s4zd8Nmwy3nJlZkyUDxdUNq+zvBoBEtHF1k17rhArbk=; b=XiOn/+yGg2pK oA4VqvTP+JnrQsZuoEh6PqyAU6PLfFcq3vzHty1tj8Oq5q41n22i+zZ6guxZbQgq h21n7yPlEl1WpAwpE7PX5sY2y63wxMKTwe5/QQVw1cyCOeE6ZRqU5dFy4TwYHz3o qzR0wiM2TVVOHfLfQ/3f0el6AdiTkjqNRevrT+NSggtEPJCNaD+1tjTYeQuxb+02 Vka54TXlbyBW1FQasAjWRDHp006XIa2kDFJdbAqEtHw4F4hrB4hJjXoQj0/zcbDI ClPgR33NtBK5HswLD11/FeKVTOxkzwj4hFC+4p/gosgUjTYMyZP8CtUCK9mwvBPz QBx9zZnOphPktWD3MVEaOFLGgbFbzThycb0uDZHfMB0PNQa1QzC2HJ8GbobsywPv 9fqXxoVJfu6fro7O/BvZOE6NLyZ4TpvALxyz87gtTFoLSMkmwU43P1S0t0xMMuj+ aE8/OmDDW4jSncSx07sS6zW+ehq+1fN7RqAfO4J0BrlaEBYni9dvSqdM5BP6jmzJ JS6Cpb3uY11EfTImDmUEXQxM3bvMlB9xeHFcHDJWG03OFSPTuu+TBj5HUMC4ns2a syxJ99gmWs0t4/ZGCXaDWOAQHAk/9tGcfbgCWmYFhdJutgJNaVU7IOG11nH+ch4f +s8VzIYLS3mQWHpVg0bSIQhMQ0xf1fE= X-Virus-Scanned: amavis at mykolab.com X-Spam-Score: -0.999 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out011.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id vggHu3rxf9VS; Fri, 5 Apr 2024 21:58:57 +0200 (CEST) Received: from int-mx009.mykolab.com (unknown [10.9.13.9]) by mx.kolabnow.com (Postfix) with ESMTPS id 51EFC2096DC2; Fri, 5 Apr 2024 21:58:57 +0200 (CEST) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx009.mykolab.com (Postfix) with ESMTPS id 0ABFB20E33D5; Fri, 5 Apr 2024 21:58:57 +0200 (CEST) From: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= To: gcc-patches@gcc.gnu.org Cc: hjl.tools@gmail.com, rguenther@suse.de, hubicka@ucw.cz, ro@CeBiTec.Uni-Bielefeld.DE, =?utf-8?q?J=C3=B8rgen_Kvalsvik?= Subject: [PATCH 2/2] Copy condition->expr map when inlining [PR114599] Date: Fri, 5 Apr 2024 21:58:31 +0200 Message-Id: <20240405195831.2728853-3-j@lambda.is> In-Reply-To: <20240405195831.2728853-1-j@lambda.is> References: <20240405195831.2728853-1-j@lambda.is> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org When a function is tree-inlined, copy the condition -> expression mapping from the inlined function into the caller, shifted so uids are not mixed Tree inlining was always problematic under condition coverage - either through a nullptr dereference (like in the test case), or through quietly mixing conditions when the assigned IDs overlapped. PR middle-end/114599 gcc/ChangeLog: * tree-inline.cc (add_local_variables): Copy cond_uids mappings. gcc/testsuite/ChangeLog: * gcc.misc-tests/gcov-pr114599.c: New test. --- gcc/testsuite/gcc.misc-tests/gcov-pr114599.c | 25 ++++++++++++++++++++ gcc/tree-inline.cc | 20 +++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.misc-tests/gcov-pr114599.c diff --git a/gcc/testsuite/gcc.misc-tests/gcov-pr114599.c b/gcc/testsuite/gcc.misc-tests/gcov-pr114599.c new file mode 100644 index 00000000000..e4c78c9c121 --- /dev/null +++ b/gcc/testsuite/gcc.misc-tests/gcov-pr114599.c @@ -0,0 +1,25 @@ +/* PR middle-end/114599 */ +/* { dg-do compile } */ +/* { dg-options "-fcondition-coverage" } */ + +/* Check that a function with a condition inlined into a function without a + conditional works. When inlining happens the condition -> expression + mapping must be carried over. */ + +extern int type; + +void fn (void); + +__attribute__((always_inline)) +inline void +do_all_fn_doall_arg (void) +{ + if (type) + fn (); +} + +void +do_all_fn_LHASH_DOALL_ARG_arg2 (void) +{ + do_all_fn_doall_arg (); +} diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index eebcea8a029..b18917707cc 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -4659,7 +4659,8 @@ prepend_lexical_block (tree current_block, tree new_block) BLOCK_SUPERCONTEXT (new_block) = current_block; } -/* Add local variables from CALLEE to CALLER. */ +/* Add local variables from CALLEE to CALLER. If set for condition coverage, + copy basic condition -> expression mapping to CALLER. */ static inline void add_local_variables (struct function *callee, struct function *caller, @@ -4689,6 +4690,23 @@ add_local_variables (struct function *callee, struct function *caller, } add_local_decl (caller, new_var); } + + /* If -fcondition-coverage is used and the caller has conditions, copy the + mapping into the caller but and the end so the caller and callee + expressions aren't mixed. */ + if (callee->cond_uids) + { + if (!caller->cond_uids) + caller->cond_uids = new hash_map (); + + unsigned dst_max_uid = 0; + for (auto itr : *callee->cond_uids) + if (itr.second >= dst_max_uid) + dst_max_uid = itr.second + 1; + + for (auto itr : *callee->cond_uids) + caller->cond_uids->put (itr.first, itr.second + dst_max_uid); + } } /* Add to BINDINGS a debug stmt resetting SRCVAR if inlining might