From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by sourceware.org (Postfix) with ESMTPS id BBA2A392AC14 for ; Sun, 2 Jun 2024 17:22:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBA2A392AC14 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 BBA2A392AC14 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717348952; cv=none; b=AmtmgeLgHMVq4FXDNgpAcwFNUQuRfEuyrjFh87/kdnxhC6NZP+B6EOXrmCFdJ3i8V9e09OWzTjVzOwiiG7xkTJP278Rbwd8h6NTILJchjm4ekwm4JHPT/C3ytT0DhBCGPIzWGvdr8qalUcMUVkL7cmf1a6E6grt8n0sojmp2KLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717348952; c=relaxed/simple; bh=zDX6EZmBtYhszk1lMHedcKXXie0OSsfWnf/zPeWmYII=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kwZaQAcGamoDPwOCQlEgXFA3IuGRU4AOPZ8I4oW/7RAYE7IzsL9sVsmZOXnDI9U5k6WI8piz6faUKSqk3rX77rbLnN/WORsRC/U/KcJlFKyH3TlwCjDR7OYzGG6k86VG3XNLnpcNJrZJZuDGsX9QAaEDNHK4imOCV6GyWsRO61M= 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=1717348951; x=1748884951; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zDX6EZmBtYhszk1lMHedcKXXie0OSsfWnf/zPeWmYII=; b=S7XH3B5+PL/36UjEhEKW0fws34obCjr0hFLpO7/mjyPqj7d0kLA5a9xA NkniaIh6ptAkKDcv/DdT6Jz/uHgM8vvWxoXhcE730N9+/nURRAuRMeMqF QvoZG5aQchYpk8qPO3lsYtWC4loFdOu4+Af+VEmDYJ9n/Jb6IRiS5+4o0 pabtQvfevip+U8YqDp4TeOOKSggH9JaVldB3uhBwzIviYsE5xWuHcVC02 6wJm6Ast9QC0oHsKT5v0dkzopcNlxppbF7VEFTjlSSODeT9cADRrYIbPr f/jGdSLq9pNTo4gsxfO3o0Lwz4E62gU1f1o9Ey9QVnZJ6ABonKW00SU17 Q==; X-CSE-ConnectionGUID: +RPPfyndRy2NTJeewWsC1A== X-CSE-MsgGUID: M+BkQMhKTze0d34ntkNzog== X-IronPort-AV: E=McAfee;i="6600,9927,11091"; a="24418951" X-IronPort-AV: E=Sophos;i="6.08,209,1712646000"; d="scan'208";a="24418951" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2024 10:22:19 -0700 X-CSE-ConnectionGUID: //dbkCkRQ92/VkVSRUGQ8g== X-CSE-MsgGUID: XqSIJO7LT/WT6LtcFk6GQw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,209,1712646000"; d="scan'208";a="41088191" Received: from tassilo.jf.intel.com ([10.54.38.190]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2024 10:22:18 -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 v7 9/9] Add documentation for musttail attribute Date: Sun, 2 Jun 2024 10:16:53 -0700 Message-ID: <20240602172205.2151579-10-ak@linux.intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240602172205.2151579-1-ak@linux.intel.com> References: <20240602172205.2151579-1-ak@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 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,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: 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 799a36586dc9..1984e8c1beec 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9921,7 +9921,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 @@ -9978,6 +9978,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 tail calls may not be supported. +Tail calls cannot reference locals in memory, which may affect +builds without optimization when passing small structures, or passing +or returning large structures. @end table @node Attribute Syntax @@ -10101,7 +10118,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