From patchwork Mon Jul 8 16:56:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1958058 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=RR6ZlrDa; 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 4WHr6N1VL0z1xpP for ; Tue, 9 Jul 2024 03:03:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 581D2384A458 for ; Mon, 8 Jul 2024 17:03:06 +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.11]) by sourceware.org (Postfix) with ESMTPS id 26DBA384A49D for ; Mon, 8 Jul 2024 17:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26DBA384A49D 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 26DBA384A49D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720458063; cv=none; b=v1t76RCU3xTvDNy6UPmGf5uFUfjgT2DLomzIYwDJ8BnedyBWxKPlq2RKHvz8kVrgFKcUOoftSKVR/ICftpJjIXeCTIwtAv8LVb9YMMZDEM9wnlvYFFrRCvOa8GXJILZDZtD46EpghyE4j9G9xEjgGiz515cR6rcqDIsTOuauMqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720458063; c=relaxed/simple; bh=R9yVboVF86B0rSLj1zmi+nzq36+W/lhqf312uJAHf6s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=m3+IuJpRq0GfuRosO6RdQP3aPfuRKTdk9w3QYhFSKx/swnbSVupk/pkD6B7DHz8b5ChnY+u6BX0GdNYulVmmMohQdmNIRZYb2noaY/bgNgIzdD6tTNnue6wCy9diZmu2rQlXR/GIkIm9L/l+DYgJytP4khiw5dcPO2VvCycBqV4= 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=1720458058; x=1751994058; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R9yVboVF86B0rSLj1zmi+nzq36+W/lhqf312uJAHf6s=; b=RR6ZlrDaiAEWx9NX2clHvr3xBPlI9IyXZtlKzt6fk71ydOhb/K/id+G7 u/WSKCAqolsWxe4OKMlMeGBG+hAy4tileYT9S80WbXwMIrJdhigAfTaU+ Ib/9v3mYNkBGSBPWdfCfoIyovtfrZWyWR1K7PfBMcqhPnjD7bybl4D8kc is2lxit5VIP54bbCeB0tAlk1mIs3oPu/EyzWsBhuVitb6zfJP3rn62PjL KFGWWmEbibRpyAqYW+AFqzgwxJrZkYXefqJgSvsZ0GGaPm7zzo1OPIJkK Jta3ivG3PdiQrxOt66d3JkZ/zSh3nJYeD1IilfsH1tIYgr5kG6n8pp1Wa g==; X-CSE-ConnectionGUID: b1MF8TQ5TP2FZ1Cd8B+Gpw== X-CSE-MsgGUID: RmuiGTxaTbWu2RWmRkaTug== X-IronPort-AV: E=McAfee;i="6700,10204,11127"; a="28279693" X-IronPort-AV: E=Sophos;i="6.09,192,1716274800"; d="scan'208";a="28279693" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2024 10:00:37 -0700 X-CSE-ConnectionGUID: d+MT5l9+SH62/CvavJxcVQ== X-CSE-MsgGUID: dyp8IPb7TgiTKcXvhcJwFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,192,1716274800"; d="scan'208";a="47486301" Received: from tassilo.jf.intel.com ([10.54.38.190]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2024 10:00:38 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, josmyers@redhat.com, polacek@redhat.com, jakub@redhat.com, Andi Kleen Subject: [PATCH v9 09/10] Add documentation for musttail attribute Date: Mon, 8 Jul 2024 09:56:01 -0700 Message-ID: <20240708170031.1621184-10-ak@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240708170031.1621184-1-ak@linux.intel.com> References: <20240708170031.1621184-1-ak@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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: PR83324 * 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