From patchwork Sat Jun 22 18:54:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1951124 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=KMNcEDZA; 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 4W63T219fWz20X6 for ; Sun, 23 Jun 2024 05:00:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 635D9385DDE1 for ; Sat, 22 Jun 2024 19:00:20 +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.17]) by sourceware.org (Postfix) with ESMTPS id AB55F385DDE3 for ; Sat, 22 Jun 2024 18:56:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB55F385DDE3 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 AB55F385DDE3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719082589; cv=none; b=XWXi6ZYTde5yx36TaoL8ucq1Cc0VxFNR66rnRfzwawwzrG+EkrWh36jwlnaNs2hNpe8yfL4vquuVP0yvBwdiDTNoxBruyd3o2cLsmwFWhGKAT8MhN/8UWl7YSHUD/kaCBPtlY3QjzQLJ0pwMT9J9vCC0p/Kx4b6nk9yMZfDXI1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719082589; c=relaxed/simple; bh=Jryz1sYg/OJr3N4m1PAlmFhlf5Jd71+hw359hXOhCI4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YeTabuVJyruX4lUqe1wPYGp5riRvjBoTLrLreqZmSGD364/ECa0YLVmAQqpCVkIKbNDcdrEWITjApVsuD5SFKpH+rhIh2bKk4h9+MsHpL9yOJsnc3+9mHRU/SochVzPeEZFOHij23tWfm93umZM5rg5AAgbyOyZBZ79N8pEkC/E= 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=1719082585; x=1750618585; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jryz1sYg/OJr3N4m1PAlmFhlf5Jd71+hw359hXOhCI4=; b=KMNcEDZApP3hkIxo0v1IzHo0SdKB2gDZPIyBGXdTZbzdAxqk2WzucIHA KusGfY0aESMM9V9sZNo3p3qksNGXJrftK6KLiQJHbGhYzlrkwtJLlNUw3 kCpWlZACusjI6hBVo6GpJ5ZB30kDjQBfJvx+wjLYdykQZQcTrinDV9Er2 hap3fGOBwapmKvedeEXk+n7Dzm/YzcF6HxbJRwM+YTJ1SEUncuUSY4fVC ct10HSOLbW8PVfFOqMwo9AZxMHcnYIcJ+E9HVmq+0qy9E3Exnh6Qq/ISr NSFRerIPNbh+Fs39J8jHRZZBQ5EFjQRlwFF3h7+1kxoYq6r8UzpaYMalb Q==; X-CSE-ConnectionGUID: E8EpS3OfRZGAFoRF/C5uXA== X-CSE-MsgGUID: vnHWUEKVRRynJnPI1+WszA== X-IronPort-AV: E=McAfee;i="6700,10204,11111"; a="16216446" X-IronPort-AV: E=Sophos;i="6.08,258,1712646000"; d="scan'208";a="16216446" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2024 11:56:06 -0700 X-CSE-ConnectionGUID: sWw99aFTSsKfou9NQO+sGA== X-CSE-MsgGUID: 3oFHoWOeSK2jnkfOfdnS5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,258,1712646000"; d="scan'208";a="42968341" Received: from tassilo.jf.intel.com ([10.54.38.190]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2024 11:56:05 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH v8 10/12] Add documentation for musttail attribute Date: Sat, 22 Jun 2024 11:54:42 -0700 Message-ID: <20240622185557.1589179-11-ak@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240622185557.1589179-1-ak@linux.intel.com> References: <20240622185557.1589179-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 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index b2e41a581dd1..f83e643da19c 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,25 @@ 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, so it is safe to use tail recursion +to implement long running loops. + +@smallexample +[[gnu::musttail]] return foo(); +@end smallexample + +If the compiler cannot generate a @code{musttail} tail call it will report +an error. On some targets tail calls may never 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. Enabling -O1 or -O2 can improve +the success of tail calls. @end table @node Attribute Syntax @@ -10101,7 +10120,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