From patchwork Tue May 21 14:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1937464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=J++ieftZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VkH6D5PsMz1ynR for ; Wed, 22 May 2024 00:35:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 067AE384CBA1 for ; Tue, 21 May 2024 14:35:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by sourceware.org (Postfix) with ESMTPS id 1B5E53858000 for ; Tue, 21 May 2024 14:32:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B5E53858000 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 1B5E53858000 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716301952; cv=none; b=cv4Cqi7DcBVL++y6WmYxeKUpe6pnjIfVsjNVlLs1e3u6Djgkf5WUwpFxVp4Re9btVyuvg5qiLZPIpd/lEpyYMdp/QMsVYYpLwxLBC1EEJVaAwQZwYuvjm7AUIeyuj8+quROxd8bHnV3xzPyCtYOFhSYD715F9sDT4s+PUJ8/wwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716301952; c=relaxed/simple; bh=dGPiVj4B88toym1iD1ANZ0v6CS1LpSpzgVyNfG49LrU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qKgAoaA5h3JpI8M3nNYVzplqpKskW8vT/UUWtqY3W1dr7GDHfS1eYgSjyj5QDwbiyYLaUBB5ao+VCAIWIAJ2932BwdHBGEaSKSyNalXT/7PfehehtwSoPNCOXi2kcDqyT0w6rGOtJjWBCR/ZmmmfjhhVTC0R2aPjliU9SBFxUCM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716301950; x=1747837950; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dGPiVj4B88toym1iD1ANZ0v6CS1LpSpzgVyNfG49LrU=; b=J++ieftZQBT8s+Ba7ElCMwBQ/fQMlGIW+RYC4HySIu+qehEJbckVFgOW j7XLzTvH0cvWStOj1tQsg56iJuHwjDUE6EWkdP+3tSYuPY11Dtx6lAqDt PcO4MC+MQ/2fDVW0q1l5WfYx87kNFzTUhmG+tAcIJ7VNunzd4IB3uDQXn eGgm4Ww0v+HYAAFriyVk7t/HXOXogjGTHFgxPP/ugbdo4aXrSFpNeqWCt XRPD1XvdQUuj1DeMzmVYdgy4ux8R+XCvrknBROtvq26z2kn1aHB2r5Mpq 3074B2/P8t9vKgO9qWxsyteZX73InUOFLF5T+fT9JT4cuGHdOo7WqslIo A==; X-CSE-ConnectionGUID: qT07PlB7SjSUEFq87Jnlig== X-CSE-MsgGUID: Z6XB/I0FQ0CU/itU7Tz7iw== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="16328297" X-IronPort-AV: E=Sophos;i="6.08,178,1712646000"; d="scan'208";a="16328297" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 07:32:20 -0700 X-CSE-ConnectionGUID: odmnYI+NRaCD7oRvlqibew== X-CSE-MsgGUID: 6D8Gi40yQdaNVvnnxqBzqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,178,1712646000"; d="scan'208";a="64166858" Received: from tassilo.jf.intel.com ([10.54.38.190]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2024 07:32:20 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, nathan@acm.org, josmyers@redhat.com, richard.sandiford@arm.com, jason@redhat.com, Andi Kleen Subject: [PATCH v6 8/8] Add documentation for musttail attribute Date: Tue, 21 May 2024 07:28:41 -0700 Message-ID: <20240521143203.2893096-9-ak@linux.intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240521143203.2893096-1-ak@linux.intel.com> References: <20240521143203.2893096-1-ak@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org gcc/ChangeLog: * doc/extend.texi: Document [[musttail]] --- gcc/doc/extend.texi | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index e290265d68d3..f3df7688edf1 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 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 @@ -9896,6 +9896,23 @@ 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 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 generates +an error. On some targets they may not be supported. +Tail calls cannot reference locals in memory, which may affect +builds without optimization when passing structures that +would fit into registers. @end table @node Attribute Syntax @@ -10019,7 +10036,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