aboutsummaryrefslogtreecommitdiff
path: root/gcc/profile.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2025-04-04 20:53:19 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2025-04-04 20:53:19 +0200
commitc89714d9df3ad8dd6b79946da85f5e276aba83db (patch)
tree9c83462fffdcfffccef448adbad019b6f4e6601f /gcc/profile.cc
parentd060d7a3ddc1c782e2800b1f68a2eb8f0de1fc32 (diff)
downloadgcc-c89714d9df3ad8dd6b79946da85f5e276aba83db.zip
gcc-c89714d9df3ad8dd6b79946da85f5e276aba83db.tar.gz
gcc-c89714d9df3ad8dd6b79946da85f5e276aba83db.tar.bz2
profile: Another musttail fix [PR119618]
As the following testcase shows, sometimes we can have debug stmts after a musttail call and profile.cc in that case would incorrectly allow the edge from that, causing musttail error and -fcompare-debug failure (because if there are no debug stmts after it, then musttail is found there and the edge is ignored). The following patch uses gsi_last_nondebug_bb instead of gsi_last_bb to find the musttail call. And so that we don't uselessly skip over debug stmts at the end of many bbs, the patch limits it to cfun->has_musttail functions. 2025-04-04 Jakub Jelinek <jakub@redhat.com> PR gcov-profile/119618 * profile.cc (branch_prob): Only check for musttail calls if cfun->has_musttail. Use gsi_last_nondebug_bb instead of gsi_last_bb. * c-c++-common/pr119618.c: New test.
Diffstat (limited to 'gcc/profile.cc')
-rw-r--r--gcc/profile.cc5
1 files changed, 3 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)