diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-04-01 11:45:16 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-04-01 11:45:16 +0200 |
commit | b8de7704428dfe008d195d8da95d6772153b0cc7 (patch) | |
tree | b3a31525f6b65bf90f612c7f044ad36a91fc620c /gcc/testsuite/c-c++-common | |
parent | 02409a145946ca0d4f502f43fc3cc20de8b3dea1 (diff) | |
download | gcc-b8de7704428dfe008d195d8da95d6772153b0cc7.zip gcc-b8de7704428dfe008d195d8da95d6772153b0cc7.tar.gz gcc-b8de7704428dfe008d195d8da95d6772153b0cc7.tar.bz2 |
profile: Another profiling musttail call fix [PR119535]
As the following testcase shows, EDGE_FAKE edges from musttail calls to
EXIT aren't the only edges we should ignore, we need to ignore also
edges created by the splitting of blocks for the EDGE_FAKE creation that
point from the musttail calls to the fallthrough block, which typically does
the return or with PHIs for the return value.
2025-04-01 Jakub Jelinek <jakub@redhat.com>
PR gcov-profile/119535
* profile.cc (branch_prob): Ignore any edges from bbs ending with
musttail call, rather than only EDGE_FAKE edges from those to EXIT.
* c-c++-common/pr119535.c: New test.
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r-- | gcc/testsuite/c-c++-common/pr119535.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/pr119535.c b/gcc/testsuite/c-c++-common/pr119535.c new file mode 100644 index 0000000..fd88cc4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr119535.c @@ -0,0 +1,31 @@ +/* PR gcov-profile/119535 +/* { dg-do compile { target musttail } } */ +/* { dg-options "-fprofile-generate -O2" } */ +/* { dg-require-profiling "-fprofile-generate" } */ + +[[gnu::noipa]] int +foo (int x) +{ + return 42 + x; +} + +int +bar (int x) +{ + foo (x); + foo (2); + [[clang::musttail]] return foo (3); +} + +int +baz (int x) +{ + if (x == 42) + return -1; + else if (x == 15) + return 25; + else if (x == 26) + [[clang::musttail]] return foo (4); + else + [[clang::musttail]] return foo (5); +} |