aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/profile.cc5
-rw-r--r--gcc/testsuite/c-c++-common/pr119618.c21
2 files changed, 24 insertions, 2 deletions
diff --git a/gcc/profile.cc b/gcc/profile.cc
index 550c85b97..6234dd2 100644
--- a/gcc/profile.cc
+++ b/gcc/profile.cc
@@ -1341,9 +1341,10 @@ branch_prob (bool thunk)
ignored_edges++;
}
/* Ignore edges after musttail calls. */
- if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
+ if (cfun->has_musttail
+ && e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
{
- gimple_stmt_iterator gsi = gsi_last_bb (e->src);
+ gimple_stmt_iterator gsi = gsi_last_nondebug_bb (e->src);
gimple *stmt = gsi_stmt (gsi);
if (stmt
&& is_gimple_call (stmt)
diff --git a/gcc/testsuite/c-c++-common/pr119618.c b/gcc/testsuite/c-c++-common/pr119618.c
new file mode 100644
index 0000000..a56e669
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr119618.c
@@ -0,0 +1,21 @@
+/* PR gcov-profile/119618 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-fcompare-debug -fprofile-generate -O1" } */
+/* { dg-require-profiling "-fprofile-generate" } */
+
+struct S { char s; };
+int foo (void);
+int *(*fn) (void);
+
+int *
+bar (void)
+{
+ if (foo ())
+ return 0;
+ {
+ struct S s;
+ do
+ [[gnu::musttail]] return fn ();
+ while (0);
+ }
+}