From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id F199D3858409 for ; Mon, 5 Feb 2024 13:33:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F199D3858409 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=linux.intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F199D3858409 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707139985; cv=none; b=moOIxDTi1paJORpw17uAHUdcRYpxkAr5PrhmYuBqEZ4Q+qY2f/x39HEHGYB4WsRFrsqIFHSfzmW41X/kMU38vkgPgquSk9RU97eQqgZnT+5+8ncxsKyq5SHWITRcCNePYtuYaOr6HVlDAvP2Yu9xIpeS0Yj2/GMgRtYN8vG45FQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707139985; c=relaxed/simple; bh=YNxtwiC5w1iTvjaSm9RaxvnTxbb0nHHoeb9Z7Gkhehs=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=t+YCXI7UDsgMFXQdx7Ua7gxIgIfLusKU0RydWiu56KWpGCcywHgapPJ3WYRAMDrcDHbuglSLOTSIK8C7BZVJPLRS+OdEzgsv4Nhvj/Y3vEqUZv/Kgo9bIhXQu1ZK3u99raWkC98dMQlDkPmsSVLPnmWuDzRZkqTGUram6DXTJMM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWz5o-0000ml-5d for gcc-patches@gnu.org; Mon, 05 Feb 2024 08:33:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707139980; x=1738675980; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=YNxtwiC5w1iTvjaSm9RaxvnTxbb0nHHoeb9Z7Gkhehs=; b=dn0wnM7oPccaAtmtsnfJXFXSX9/aaJr8XwE/9RhVI0mKGjmRSe2R/2DW H/QLHuwDDN2OjsRuW7qhZ18lYrVoTuTdD3xRIIVljgzc0mp0DO2f/3DC/ R3Z/ek523jqT2xuZZxUCHzZWc0IJqQlFkmQhej2eVxBUuTDbGiBBwyVT7 9FFD4i+RwOZZqSub8qwYITw8qRUG59obucChKNYAJ4m23QyHPrF9crBms FwUGhNjwRxrCV+o/vZRSIzRzPHeHbsmcVGjzTHawGslgbasji+HWPKJ9s ZXMyYTM4X3g1OXunS1u7YkS40/7YP+K6GlKJUey/kf/CR4R2T3o8Z5P6j w==; X-IronPort-AV: E=McAfee;i="6600,9927,10974"; a="4403743" X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="4403743" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 05:32:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="713291" Received: from tassilo.jf.intel.com (HELO tassilo) ([10.54.38.190]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 05:32:56 -0800 Date: Mon, 5 Feb 2024 05:32:54 -0800 From: Andi Kleen To: Sandra Loosemore Cc: gcc-patches@gnu.org Subject: Re: [PATCH v4 5/5] Add documentation for musttail attribute Message-ID: References: <20240202091322.1898280-1-ak@linux.intel.com> <20240202091322.1898280-6-ak@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Received-SPF: none client-ip=198.175.65.15; envelope-from=ak@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9,DKIMWL_WL_HIGH=-0.285,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_EF=-0.1,SPF_HELO_NONE=0.001,SPF_NONE=0.001,T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 Sat, Feb 03, 2024 at 09:35:43PM -0700, Sandra Loosemore wrote: > On 2/2/24 02:09, Andi Kleen wrote: > > gcc/ChangeLog: > > > > * doc/extend.texi: Document [[musttail]] > > --- > > gcc/doc/extend.texi | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi > > index 142e41ab8fbf..866f6c4a9fed 100644 > > --- a/gcc/doc/extend.texi > > +++ b/gcc/doc/extend.texi > > @@ -9875,6 +9875,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 return statement that returns the value > > +of a call to indicate that the call must be a tail call > > +that does not allocate extra stack space. > > It took me about 3 attempts to parse this. :-S I think this might be a > little better: > > ...can be applied to a @code{return} statement with a return-value > expression that is a function call. It asserts that the call must be a tail > call that does not allocate extra stack space. > > > + > > +@smallexample > > +[[gnu::musttail]] return foo(); > > +@end smallexample > > + > > +If the compiler cannot generate a tail call it will generate > > s/will generate/generates/ > > I'm a big fan of writing in the present tense. ;-) > > > +an error. Tail calls generally require enabling optimization. > > +On some targets they may not be supported. > > + > > @end table > > @node Attribute Syntax > > In addition to these changes, at the beginning of this section we have > > @node Statement Attributes > @section Statement Attributes > @cindex Statement Attributes > > GCC allows attributes to be set on null statements. @xref{Attribute > Syntax}, > for details of the exact syntax for using attributes. [...] > > Well, we now have an attribute that goes on a non-null statement, so we have > to fix this. The documentation for the other statement attributes is FWIW we always had, they just were ignored (with a warning) Thanks Sandra. I applied the changes. Diff appeneded for reference. diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 866f6c4a9fed..fe1ee245ed69 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9818,7 +9818,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 Syntax}, +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}), enumerators @@ -9879,15 +9879,15 @@ have to optimize it to just @code{return 42 + 42;}. @item musttail The @code{gnu::musttail} or @code{clang::musttail} attribute -can be applied to a return statement that returns the value -of a call to indicate that the call must be a tail call -that does not allocate extra stack space. +can be applied to a @code{return} statement with a return-value expression +that is a function call. It asserts that the call must be a tail call that +does not allocate extra stack space. @smallexample [[gnu::musttail]] return foo(); @end smallexample -If the compiler cannot generate a tail call it will generate +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. @@ -10014,7 +10014,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