]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/114681 - condition coverage and inlining
authorRichard Biener <rguenther@suse.de>
Thu, 11 Apr 2024 06:47:19 +0000 (08:47 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 11 Apr 2024 09:03:56 +0000 (11:03 +0200)
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.

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 [new file with mode: 0644]
gcc/tree-inline.cc

diff --git a/gcc/testsuite/gcc.misc-tests/gcov-pr114681.c b/gcc/testsuite/gcc.misc-tests/gcov-pr114681.c
new file mode 100644 (file)
index 0000000..a8dc666
--- /dev/null
@@ -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 ();
+}
index 5f852885e7f14b6904d42e9280d84a58132e2636..238afb7de80ebe058bb3a814b4876fc632f36921 100644 (file)
@@ -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);