From patchwork Sun May 5 18:14:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1931591 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=POgyFMmM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4VXXm34zkqz213x for ; Mon, 6 May 2024 04:16:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D13423844042 for ; Sun, 5 May 2024 18:16:01 +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 [192.198.163.9]) by sourceware.org (Postfix) with ESMTPS id B75CF385843B for ; Sun, 5 May 2024 18:15:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B75CF385843B 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 B75CF385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714932935; cv=none; b=QasUxnzdSA+O5ORVuSMYn/vR/vl/d7kc5dP8zUDDD51W9HgiAwdz5pm5OGtVbqvOxrx8poV56xMpFhKCK47tVmX+UCYtUGa/hyrNFak1glivyMKLj5q07JNT8jrrY2sX7ibTsCEASxZoxWl2VbrADu8nrXx6ePmBHZn+Arjo4cE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714932935; c=relaxed/simple; bh=F23XnbzfWiFMcm6O9iCI3HZF3waNYMTl+yGy/xwsKg4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pVqwwiYu2emJCiAteTHxgjFtil/s4SXkwTdM7RwEp2ITb/Wy7/duOxjVpfqXxI6qWa/gBqRLAYHZaKPgJunBm874gc+dodY4gMhpwdU6LEyXlA8X5ATChmb3ny6R947nxU6g72d3LmtahcfqLqUcMb76SXVludHTAJvaC32FnQI= 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=1714932934; x=1746468934; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F23XnbzfWiFMcm6O9iCI3HZF3waNYMTl+yGy/xwsKg4=; b=POgyFMmMIRtsRptxlSIJXMJdksKkcTfh1nxm/F9Ca3HqrNlKQP8qRCk3 60zasqNP8h8mJH52hU7lV9ENkkMFHLIAIqDqVSVffd8lc+lF/qdG8rKuu I0Pk+MJNvdkTYlb8CpMjkw/cx6cxSdzd4esUdispSV1hssBVWhTrQW0wM oSU38KNFPHvIHVDDQ67y77ChUoRNhTNOm96R7TgXdDOBjX2cK/Uu5wNZg waWjt3iGb5jg3d/T4sFUyfMJ29fvPO81lmi8KstQNw1UKLoFIEKYt/ZoH kmTYh8CnN3pYuee2f5oa3FLsHbQePRHphvnDz8Dedqobnplo98v5Uecoq g==; X-CSE-ConnectionGUID: MHyWEZOwR3GyVjqIETUW9w== X-CSE-MsgGUID: sYxZ1cZFT1WL0yRkQz09sQ== X-IronPort-AV: E=McAfee;i="6600,9927,11064"; a="21356331" X-IronPort-AV: E=Sophos;i="6.07,256,1708416000"; d="scan'208";a="21356331" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2024 11:15:26 -0700 X-CSE-ConnectionGUID: bmSUdwefQF6bns6R54N5+w== X-CSE-MsgGUID: 4ZSrR21eQL2uhrH1G3Xx3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,256,1708416000"; d="scan'208";a="28457583" Received: from tassilo.jf.intel.com ([10.54.38.190]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2024 11:15:26 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: nathan@acm.org, josmyers@redhat.com, richard.sandiford@arm.com, jason@redhat.com, Andi Kleen Subject: [PATCH v5 5/5] Add documentation for musttail attribute Date: Sun, 5 May 2024 11:14:58 -0700 Message-ID: <20240505181458.2903045-5-ak@linux.intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240505181458.2903045-1-ak@linux.intel.com> References: <20240505181458.2903045-1-ak@linux.intel.com> MIME-Version: 1.0 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_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 | 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 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,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 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. Tail calls generally require enabling optimization. +On some targets they may not be supported. + @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