From: Richard Biener Date: Thu, 11 Apr 2024 06:47:19 +0000 (+0200) Subject: middle-end/114681 - condition coverage and inlining X-Git-Tag: basepoints/gcc-15~228 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52b63100b1eda433120e726d4e8f8dfca6fc94fa;p=thirdparty%2Fgcc.git middle-end/114681 - condition coverage and inlining 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. --- 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 000000000000..a8dc666a452d --- /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 5f852885e7f1..238afb7de80e 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);