public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] middle-end/114681 - condition coverage and inlining
Date: Thu, 11 Apr 2024 11:03:23 +0200 (CEST)	[thread overview]
Message-ID: <20240411090323.qEMbJ5GknFlMlgVCDLdfdKUV3hbRqxMhlJAZygwpFE4@z> (raw)

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 <gcond*> (orig_stmt))
+	  if (id->src_cfun->cond_uids && is_a <gcond*> (stmt))
 	    {
 	      gcond *orig_cond = as_a <gcond*> (orig_stmt);
 	      gcond *cond = as_a <gcond*> (stmt);
-- 
2.35.3

                 reply	other threads:[~2024-04-11  9:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240411090323.qEMbJ5GknFlMlgVCDLdfdKUV3hbRqxMhlJAZygwpFE4@z \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).