From patchwork Thu Apr 11 09:03:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 88341 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2019E384AB61 for ; Thu, 11 Apr 2024 09:03:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 91863385841F for ; Thu, 11 Apr 2024 09:03:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91863385841F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 91863385841F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712826206; cv=none; b=GzKJM0Vc1Nkn0R4sIq5R092QhjUS2PV3o62MznVa2Q32KGWMZfLsb5gkxOngLzeNEkAbVnL9NiBlmgCaRfwjXh6xBNq8ij7q61e1MEhVEr/4FxdL/ia3kU0JmlqEafmsLazNV+8VS5GPnIF35ROsxEkgICicVjsvOmvUCMQPuRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712826206; c=relaxed/simple; bh=qMeoJv0MdJF0mzDHc3I83p7/upN8B3nW3Bqx2ELn1KY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=heOkj5ivSlGpwGPP01EcG6xa17tTHpMYbrdk4+ExgmajXvJXL2R8YzPrj7yIJ2NvkFOBpqCavWL1SRX6C7w78mtlcRTKwaxWcGeGEIdZ3D5yklGspdJJ6ZlKnT2hBFSkI9cqa0aPXAH4cilkTv7RHOk8+5FtTLx+xfBFbDVGx4s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.5.241] (unknown [10.168.5.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6710A22B0C for ; Thu, 11 Apr 2024 09:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712826203; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=vta3Ew51Qgfe8U1hZAzT451QekBvp8DCX7gQd+3DLAs=; b=CEiy7K/oTVO8e3r5aWKmHYQsvQf7kULtor/d/Y9dMaiYmaEbDQmnj821EfKftIFIeQU7fV Ru1BpjUAvFcl7LKlHS5oxXdL21NutVIHGmwrWQjQVz4n7eLO5IlD7peNYyZVXgDnet0nL1 QzeZSDJNbxQI0BpaPOGxhjPXXa7g+A0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712826203; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=vta3Ew51Qgfe8U1hZAzT451QekBvp8DCX7gQd+3DLAs=; b=5kMgVWHxSAr3VaDuXuCMvHt2BXbzHxPM9gaWROKn1aOoPecly80bpaXCv0PLF7ab2gkWeU g7qjVT5HmR4ZX1Aw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712826203; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=vta3Ew51Qgfe8U1hZAzT451QekBvp8DCX7gQd+3DLAs=; b=CEiy7K/oTVO8e3r5aWKmHYQsvQf7kULtor/d/Y9dMaiYmaEbDQmnj821EfKftIFIeQU7fV Ru1BpjUAvFcl7LKlHS5oxXdL21NutVIHGmwrWQjQVz4n7eLO5IlD7peNYyZVXgDnet0nL1 QzeZSDJNbxQI0BpaPOGxhjPXXa7g+A0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712826203; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=vta3Ew51Qgfe8U1hZAzT451QekBvp8DCX7gQd+3DLAs=; b=5kMgVWHxSAr3VaDuXuCMvHt2BXbzHxPM9gaWROKn1aOoPecly80bpaXCv0PLF7ab2gkWeU g7qjVT5HmR4ZX1Aw== Date: Thu, 11 Apr 2024 11:03:23 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] middle-end/114681 - condition coverage and inlining MIME-Version: 1.0 X-Spam-Score: -1.76 X-Spam-Level: X-Spamd-Result: default: False [-1.76 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.96)[-0.963]; NEURAL_HAM_SHORT(-0.19)[-0.971]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[] X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 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+patchwork=sourceware.org@gcc.gnu.org Message-Id: <20240411090357.2019E384AB61@sourceware.org> When inlining a gcond it can map to multiple stmts, esp. with non-call EH. The following makes sure to pick up the remapped condition when dealing with condition coverage. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR middle-end/114681 * tree-inline.cc (copy_bb): Key on the remapped stmt to identify gconds to have condition coverage data remapped. * gcc.misc-tests/gcov-pr114681.c: New testcase. --- gcc/testsuite/gcc.misc-tests/gcov-pr114681.c | 18 ++++++++++++++++++ gcc/tree-inline.cc | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.misc-tests/gcov-pr114681.c diff --git a/gcc/testsuite/gcc.misc-tests/gcov-pr114681.c b/gcc/testsuite/gcc.misc-tests/gcov-pr114681.c new file mode 100644 index 00000000000..a8dc666a452 --- /dev/null +++ b/gcc/testsuite/gcc.misc-tests/gcov-pr114681.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fnon-call-exceptions -fno-exceptions -fcondition-coverage" } */ + +float f, g; + +static void +bar () +{ + if (g < f) + for (;;) + ; +} + +void +foo () +{ + bar (); +} diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index 5f852885e7f..238afb7de80 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -2090,7 +2090,7 @@ copy_bb (copy_body_data *id, basic_block bb, /* If -fcondition-coverage is used, register the inlined conditions in the cond->expression mapping of the caller. The expression tag is shifted conditions from the two bodies are not mixed. */ - if (id->src_cfun->cond_uids && is_a (orig_stmt)) + if (id->src_cfun->cond_uids && is_a (stmt)) { gcond *orig_cond = as_a (orig_stmt); gcond *cond = as_a (stmt);