public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v5 2/5] C++: Support clang compatible [[musttail]] (PR83324)
Date: Tue, 21 May 2024 14:02:32 -0400	[thread overview]
Message-ID: <27223597-d38a-4358-8699-8afa9dddf48b@redhat.com> (raw)
In-Reply-To: <ZkPydlSw-iYqXwJD@tassilo>

On 5/14/24 19:23, Andi Kleen wrote:
>>>> You need a template testcase; I expect it doesn't work in templates with the
>>>> current patch.  It's probably enough to copy it in tsubst_expr where we
>>>> currently propagate CALL_EXPR_OPERATOR_SYNTAX.
>>>
>>> I tried it with the appended test case, everything seems to work without
>>> changes.
>>>
>>> Does it cover the cases you were concerned about?
>>
>> Not fully; this testcase doesn't seem to check for errors if tail-call
>> fails, only whether the syntax is accepted.  So it would pass if the
>> attribute were simply ignored.
> 
> Okay I'm not clear how I would do that. Pattern match the assembler
> in a target specific test case? From looking at the assembler output
> everything got tail converted.

Write a testcase where the tail-call optimization can't happen, perhaps 
because the caller and callee disagree on return type:

int f();

double h() { [[gnu::musttail]] return f(); } // error

template <class T>
T g() { [[gnu::musttail]] return f(); }

int main()
{
   g<int>();
   g<double>(); // should error, but doesn't with v6 patch set
}

Jason


  reply	other threads:[~2024-05-21 18:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-05 18:14 [PATCH v5 1/5] Improve must tail in RTL backend Andi Kleen
2024-05-05 18:14 ` [PATCH v5 2/5] C++: Support clang compatible [[musttail]] (PR83324) Andi Kleen
2024-05-07  3:02   ` Jason Merrill
2024-05-14 17:24     ` Andi Kleen
2024-05-14 21:52       ` Jason Merrill
2024-05-14 23:23         ` Andi Kleen
2024-05-21 18:02           ` Jason Merrill [this message]
2024-05-05 18:14 ` [PATCH v5 3/5] C: Implement musttail attribute for returns Andi Kleen
2024-05-05 18:14 ` [PATCH v5 4/5] Add tests for C/C++ musttail attributes Andi Kleen
2024-05-05 18:14 ` [PATCH v5 5/5] Add documentation for musttail attribute Andi Kleen
2024-05-14 14:21   ` Richard Biener
2024-05-14 16:30     ` Andi Kleen
2024-05-14 17:08       ` Richard Biener
2024-05-14 14:15 ` [PATCH v5 1/5] Improve must tail in RTL backend Richard Biener
2024-05-14 17:19   ` Andi Kleen
2024-05-20  4:53   ` Andi Kleen
2024-05-21  8:31     ` Richard Biener
2024-05-21 13:35       ` Andi Kleen
2024-05-21 16:41         ` Richard Biener
2024-05-21 21:45           ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27223597-d38a-4358-8699-8afa9dddf48b@redhat.com \
    --to=jason@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).