From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id D99BE384AB7F for ; Tue, 14 May 2024 14:22:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D99BE384AB7F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D99BE384AB7F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715696531; cv=none; b=IHH5hlWDsb/QiYFcGvy7wYJKjSNsNe33f0cNMZCnHX/xHHrH/O6rxvCVxPhxRkkv9BFkjFA4xfQaWcpkclM4+D9gZ6tYtqA8AtIxcUYSoEFM0GebKL6JBVzYalvi5jWhMMeLptU7IBFGCIGEPwkOmwPL+5PNPWO05b0bWWMiLr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715696531; c=relaxed/simple; bh=kveaFzCqxIfSYJM4JsrInlfjSxkcXROcJ7fyJfKo03U=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ukpqd7NjSlgApiVLJT+hkdcljVszKO/MqAhnP9Nc6Q1Bv1t8/n1i2pN1NI7ngsB0fN/jZqhbBWiS1pR9L9zKYXIR8iZEZPyx5/jqH7Ou5bzSJoVY73Xr3QNmoDACMJ2GZ3oVHeaPRO/d5PzP75EHOuopAJDdBiHMWi2djg/fIe4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52192578b95so6601104e87.2 for ; Tue, 14 May 2024 07:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715696528; x=1716301328; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OUBw13JQetcjWgz2mYMn38cqSZd3IJfWuVY918XtXak=; b=mHn690df2ZGKDiQZF8g4nL8zViVTdE7sVr0cQbwaQlSJVq5NjmPz9X9axa4f9VTLWq RrczqB50piPWx1llmpFC2NkQ9V/cV+jNgGpKjJYlMPXPRx0KCT5XQDKuJMHG65P9ONGS EdF33gv0t79IaOppNJAwDrNWubDnCEMyqeHhUXGfdgy2m2AUwP3kQgwZpYs33ITwHtkE QR744lFk/bd56j2uFeNJvp94XHsG++qZKSmY9gfk6kfSq0LBCWh1xDeLC3bgBPb03NQj BvMAytuqbtahHQxsqpQx9XzOSwOOy90wqWH9BvPzBrbFrQgRVjEQPieglPgSmUt/XTEX VPKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715696528; x=1716301328; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OUBw13JQetcjWgz2mYMn38cqSZd3IJfWuVY918XtXak=; b=Jnz40K/gbKzVIpGFQ72OiA3biefaT9kAXVX66n2WXSBQK2H2QkJ9QFRsQ88utqVHII 52S0Em9xpOiGmRR2FkJ+7JQ7t3fjSQojxMwxGEgSAFkzwRPkHYp4Dctddt2eWUvkMyA6 y0hDoc9ptTF7OScCEQlVeyysZ0CxAOUKqgZqEWcJuooQfGTo+NHOpiMzRKgZbNvdVnmr k+quKbdlphasB4k/QzFc0QIm43+GLxXwvcpW+C7c7yeP3pKXrJSJpWq3fJ+5YMcPUEkV efQVTzBGDVYjDCevEHm2XS9gUIn/h+8e33KBdcfLZMzF7Emz0ooVd4s51zolZFZR1xPg PJSA== X-Gm-Message-State: AOJu0Ywsrf57Ox7GkjpSNMEsrhscMl+5/iYgWIYRRLIzNVWsuu0+c87+ H9KPw+I3pKJ8bFDr2PRq6qsoGogkjKxAfNXx6Zm4EP9aLXbAXzbRgZuqC+VJC6WIiqT60DwmfSh inoMA+Y+bXfDjojWf2sdXE+i7rUg= X-Google-Smtp-Source: AGHT+IHj+wLgCbY3/dE/5ZqTg+chHkouyMOE64qZIDQYulv5gDc2qkRFfQg3fA6gXFejKQ61b12A9taDiJNTg+Nx8iw= X-Received: by 2002:ac2:4e0b:0:b0:523:41ba:a289 with SMTP id 2adb3069b0e04-52341baa348mr4588827e87.4.1715696527820; Tue, 14 May 2024 07:22:07 -0700 (PDT) MIME-Version: 1.0 References: <20240505181458.2903045-1-ak@linux.intel.com> <20240505181458.2903045-5-ak@linux.intel.com> In-Reply-To: <20240505181458.2903045-5-ak@linux.intel.com> From: Richard Biener Date: Tue, 14 May 2024 16:21:56 +0200 Message-ID: Subject: Re: [PATCH v5 5/5] Add documentation for musttail attribute To: Andi Kleen Cc: gcc-patches@gcc.gnu.org, nathan@acm.org, josmyers@redhat.com, richard.sandiford@arm.com, jason@redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, May 5, 2024 at 8:16=E2=80=AFPM Andi Kleen wrot= e: > > gcc/ChangeLog: > > * doc/extend.texi: Document [[musttail]] > --- > gcc/doc/extend.texi | 22 ++++++++++++++++++++-- > 1 file changed, 20 insertions(+), 2 deletions(-) > > diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi > index e290265d68d3..deb100ad93b6 100644 > --- a/gcc/doc/extend.texi > +++ b/gcc/doc/extend.texi > @@ -9839,7 +9839,7 @@ same manner as the @code{deprecated} attribute. > @section Statement Attributes > @cindex Statement Attributes > > -GCC allows attributes to be set on null statements. @xref{Attribute Syn= tax}, > +GCC allows attributes to be set on statements. @xref{Attribute Syntax}, > for details of the exact syntax for using attributes. Other attributes = are > available for functions (@pxref{Function Attributes}), variables > (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumer= ators > @@ -9896,6 +9896,22 @@ foo (int x, int y) > @code{y} is not actually incremented and the compiler can but does not > have to optimize it to just @code{return 42 + 42;}. > > +@cindex @code{musttail} statement attribute > +@item musttail > + > +The @code{gnu::musttail} or @code{clang::musttail} attribute > +can be applied to a @code{return} statement with a return-value expressi= on > +that is a function call. It asserts that the call must be a tail call t= hat > +does not allocate extra stack space. > + > +@smallexample > +[[gnu::musttail]] return foo(); > +@end smallexample > + > +If the compiler cannot generate a tail call it generates > +an error. Tail calls generally require enabling optimization. > +On some targets they may not be supported. Looks generally OK though does this mean people can debug programs using [[gnu::musttail]] only with optimized builds? It seems to me we should try harder to make [[gnu::musttail]] work at -O0 and generally behave the same at all optimization levels? > + > @end table > > @node Attribute Syntax > @@ -10019,7 +10035,9 @@ the constant expression, if present. > > @subsubheading Statement Attributes > In GNU C, an attribute specifier list may appear as part of a null > -statement. The attribute goes before the semicolon. > +statement. The attribute goes before the semicolon. > +Some attributes in new style syntax are also supported > +on non-null statements. > > @subsubheading Type Attributes > > -- > 2.44.0 >