https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119614
--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> --- --- gcc/testsuite/g++.dg/lto/pr119614_0.C.jj 2025-04-07 08:44:32.868051786 +0200 +++ gcc/testsuite/g++.dg/lto/pr119614_0.C 2025-04-07 08:44:27.810122315 +0200 @@ -0,0 +1,34 @@ +// PR tree-optimization/119614 +// { dg-lto-do link } +// { dg-lto-options { { -O2 -fPIC -flto -flto-partition=max } } } +// { dg-require-effective-target shared } +// { dg-require-effective-target fpic } +// { dg-require-effective-target musttail } +// { dg-extra-ld-options "-shared" } + +struct S {} b; +char *foo (); +int e, g; +void bar (); +void corge (S); + +[[gnu::noinline]] static char * +baz () +{ + bar (); + return 0; +} + +const char * +qux () +{ + if (e) + { + S a = b; + corge (a); + if (g) + return 0; + [[gnu::musttail]] return baz (); + } + return foo (); +}