Message ID | 20240202091322.1898280-6-ak@linux.intel.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp303932dyc; Fri, 2 Feb 2024 01:16:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmbRlRdrJtyem4ec5w0fVxSkuN9y68tyE+UUNnp8bal/byS6LCERn+cO1mSvFew8tVUl7u X-Received: by 2002:a05:622a:84:b0:42b:fefc:b851 with SMTP id o4-20020a05622a008400b0042bfefcb851mr1641564qtw.62.1706865387416; Fri, 02 Feb 2024 01:16:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706865387; cv=pass; d=google.com; s=arc-20160816; b=RVll8zGlEEpnP6WiTI14wW6vj1+cNfofj9zT0we83zSpEQPnB/17vJVMP9nAsIYFEH egQRvkioHE/ZYJUPUAM9s0eDEdJOTzqyyYlsB1hZxZwY5HaPPCjkv1hspOkJZp4R2PUM q8+aUngZ0QgFdKSYXeyXRNJ1YtM8NAokb4R8H8AYjVBRssOoU+4dd1yLJQm+2fdztSnE SY9xmuFJUjWuOAWQWn9tfDLJZsHJY949jmM4dKxR9X/sRvTI8lWpq9Ca/KnnMVSRfZ02 NDS4ArBGB5cWyMGr+8ByYKBtztnR6EIzDDjO78Y1qpMuv7N2s89iIJv3e5wkytpCuCC9 rXNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=a7nZFexlPcdKw8eoNaNCiYSmjXAFxPiTD7W515q7e3g=; fh=36bCHlCGJ4KVHjr6XkjTl/+1k3jAHmJVWkl9Pcsil+c=; b=yY3qjYfCHbU4tUBSvHlv653jO9F+EHEChtq9n6FxFPRY20d0qUw0gVbyehyY00tw7g hMOHaL/OGQBlLZEMv3HUCPI9C9aKLXXZVOuxq/vfl4ICDRDU0ayAaCfxYJ4XWe8LkqYO XcRtm37D5/WNrrWxUaf5QMC02rCqHsBCdYifTfSldrrMjuC6Y3Zj+tqMzfD/QvzB2+0O RurGV4Qgea36x3gZOnOUfo7YQC2SjGSvbh+hDd+dDKVkafplxdppVfdpbQrx5yf5VXtz 9Clcoef9+kXMeTTROXLu9HyaYnGyTJeI5lB9C8vMMt+Z8jEWV7wiE28FcbLE1HEslItp KM3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="WFFsJ/bC"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCWCh6VkJ+djQF/65ogyyxWP/0qy1RVz7pJfcoRLNEcR4kP9c4swL6F4Xu+R08shEDNa7pB4EyIPdyr+5BYt6xPy97/bJA== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id p7-20020ac87407000000b0042c00c09c03si1364461qtq.285.2024.02.02.01.16.27 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 01:16:27 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="WFFsJ/bC"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17FA33857C40 for <ouuuleilei@gmail.com>; Fri, 2 Feb 2024 09:16:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 7F7813858414 for <gcc-patches@gcc.gnu.org>; Fri, 2 Feb 2024 09:13:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F7813858414 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 7F7813858414 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=1706865224; cv=none; b=fDbBverTIh2ocvoJOHYD32Vo2xT02Jlo0RAD/Mj3Bx2MsTXGa6hX43aTss2y1Ld+/O7uEzJKeRTuva2bdyM7ePyf76Gffg0hztNOAskZdR8SSKwob9axps5wkNFaN0oLzPZwYNASNgi+sIPqN/9KidcT6tjvI9vIJJBOos1o6P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706865224; c=relaxed/simple; bh=4XJgf9IeqAEBW+VOM/JVPlCCD6TohzsMzQUOel98ozc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=v2vVnP0ks4BNVIhc7Ddc/rUWx1inHkNlg3QYgZX3c7g8iD3x0yz+pZYJXCb2Z7glx63CQ93Q8HsyqAsl5Cf/brFh7GH2tmWlzQG7r8m3rfXTuHdryRLZGkHiPLDst716IHTNmqdY+GsIpLBTT6lyuyBnS+ItLfu0JtahiTrUX3w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mgamail.intel.com ([192.198.163.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ak@linux.intel.com>) id 1rVpcC-0004Em-JL for gcc-patches@gnu.org; Fri, 02 Feb 2024 04:13:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706865220; x=1738401220; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4XJgf9IeqAEBW+VOM/JVPlCCD6TohzsMzQUOel98ozc=; b=WFFsJ/bCUTx+RbxyZdmYe7iapUNXaU5zyTyO+/uZFH0H/hx0Em0JmJl0 7EcLuj8hM74ie+gAIRaL4JxvvuKgdRBgrkNlqbrjxAJTEDtBFDKw7r8Nz 8TpQV8ASj3Hgb/PZ5FbdO/mBSloML942Hj674TbQN/uTNzFP4yjc8lI9/ ggKOJa0sUmgfDmLrVEfQOA5fYPbldzsrno9gDskbu1GVakqf/NwJjButW WhJa7PXsh4o62/S7stJTVHpky3np/UFfH9GOHUy7y4BLmOaMuT1yt5jIo Uu2aj85t7GnG8SHF1VsdHmV/XNqXoUU7286Uc1HIwc99foNakBTn7kQxL Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="3942952" X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="3942952" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2024 01:13:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="23318068" Received: from tassilo.jf.intel.com ([10.54.38.190]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2024 01:13:30 -0800 From: Andi Kleen <ak@linux.intel.com> To: gcc-patches@gnu.org Cc: Andi Kleen <ak@linux.intel.com> Subject: [PATCH v4 5/5] Add documentation for musttail attribute Date: Fri, 2 Feb 2024 01:09:20 -0800 Message-ID: <20240202091322.1898280-6-ak@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202091322.1898280-1-ak@linux.intel.com> References: <20240202091322.1898280-1-ak@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=192.198.163.12; envelope-from=ak@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.292, 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=-13.1 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789778080342454396 X-GMAIL-MSGID: 1789778080342454396 |
Series |
[v4,1/5] Improve must tail in RTL backend
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Andi Kleen
Feb. 2, 2024, 9:09 a.m. UTC
gcc/ChangeLog: * doc/extend.texi: Document [[musttail]] --- gcc/doc/extend.texi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Comments
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 already explicit that they go on null statements so those already would be OK if we just removed the "null" restriction here. OTOH, the Attribute Syntax section, in discussing GCC's traditional attribute syntax, says: @subsubheading Statement Attributes In GNU C, an attribute specifier list may appear as part of a null statement. The attribute goes before the semicolon. If "musttail" is only supported in the standard attribute syntax, its new entry in the Statement Attributes node must say that, and the blurb at the top of the node quoted above must say something to the effect that the traditional syntax only allows statement attributes on null statements and attributes on non-null statements are only permitted in the new standard attribute form. -Sandra
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
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. + +@smallexample +[[gnu::musttail]] return foo(); +@end smallexample + +If the compiler cannot generate a tail call it will generate +an error. Tail calls generally require enabling optimization. +On some targets they may not be supported. + @end table @node Attribute Syntax