On Wed, Mar 26, 2025 at 10:10:07AM -0700, Andi Kleen wrote: > Jakub Jelinek <ja...@redhat.com> writes: > > > --- gcc/testsuite/g++.dg/opt/musttail2.C.jj 2025-03-24 13:27:44.329204196 > > +0100 > > +++ gcc/testsuite/g++.dg/opt/musttail2.C 2025-03-24 13:28:08.975867389 > > +0100 > > @@ -0,0 +1,14 @@ > > +// PR ipa/119376 > > +// { dg-do compile { target musttail } } > > I think this needs to be target external_tailcall, otherwise you will > fail on targets that don't support that. > > > +// { dg-options "-O2 -fno-early-inlining -fdump-tree-optimized" } > > +// { dg-final { scan-tree-dump-times " \[^\n\r]* = foo \\\(\[^\n\r]*\\\); > > \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } > > + > > +struct S { S () {} }; > > +char *foo (S); > > Or alternatively make this not extern.
You're right (although I don't remember which targets are non-external_musttail). Here is a patch to define the function, tested on x86_64-linux, ok for trunk? 2025-03-26 Jakub Jelinek <ja...@redhat.com> * g++.dg/opt/musttail2.C (foo): Define the function instead of just declaring it, add [[gnu::noipa]] attribute to it. --- gcc/testsuite/g++.dg/opt/musttail2.C.jj 2025-03-25 09:36:31.502487137 +0100 +++ gcc/testsuite/g++.dg/opt/musttail2.C 2025-03-26 18:17:59.827281263 +0100 @@ -4,7 +4,12 @@ // { dg-final { scan-tree-dump-times " \[^\n\r]* = foo \\\(\[^\n\r]*\\\); \\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } struct S { S () {} }; -char *foo (S); + +[[gnu::noipa]] char * +foo (S) +{ + return 0; +} char * bar (S) Jakub