From patchwork Mon Jul 8 16:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1958053 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=SyWzdeCk; 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 4WHr4W6XWFz1xpP for ; Tue, 9 Jul 2024 03:01:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2273A384A46F for ; Mon, 8 Jul 2024 17:01:30 +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 3FD413858C3A for ; Mon, 8 Jul 2024 17:00:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3FD413858C3A 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 3FD413858C3A 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=1720458054; cv=none; b=Ct2JZpgEkljEsqUW07p5vlOkMeF4lEWAMgLR5/S5yRhyfLyzr+x0WGiqlfXCofk3Q/ec24LTHZSaNJrjjdjevbpo5hq425MS6ng76IbUx3I1D5YzFk1TUp95pku5GpuAmUIteUyhzr3nLETPaskYz6NA5+tv8mWrFGTdACBLWUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720458054; c=relaxed/simple; bh=RT7E4A4VRnUq+VoEN8JX2A1iBfZ6XhS2Bz7HxIK8uUw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NE8ldLcx6jrmrJ7VH3lXaTSIsTC+Arz8dgSsUXo0r9H6lwjTZqJDyxE1BF+JnJ0OasnI0vi5umGMiRQ8sdvjuTjn1R4uLTHW+POzJxKEiwtZkMk7X4+zn9ffUnM6izG8JdOYHPulEtEHIA+swQ1eRs0inKH/rXup/l5p5I2gTBM= 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=1720458052; x=1751994052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RT7E4A4VRnUq+VoEN8JX2A1iBfZ6XhS2Bz7HxIK8uUw=; b=SyWzdeCkvk3Cf7Ryk22HbRDfD3VugqHWWfqSGwdAHhFQqrqA3DG3iNaB owYhmAl5e5ksH7eGhVRdkSjyengvXjhNLj/Syq0yI2+Zje96lIFjoA5Q9 DlOEDZrEIKanUjg/zBv/JPIQr7q05gbv1RFCqJXMvV9/7ZCB/pi20hkwJ g4gS+1nIE/m+k3G7DD7L3RSPrbYSevA2ToB0/D7JcBlU863cTT6s9/htq Hieb6mFO06jtMfvUCaUa+8lOBxztpDUm5LcnXKA6oCN/ik6io7fJ+tjfj HAFyqZ2iVGnFoDxFuTthJlUQEvfkbW0fFrbwwCJktLkDgJJII5euEWNoJ Q==; X-CSE-ConnectionGUID: f3rgvquOTdadVnvBnI7xcA== X-CSE-MsgGUID: Dq0aku0KRtmpbBBv1YvK3g== X-IronPort-AV: E=McAfee;i="6700,10204,11127"; a="28279676" X-IronPort-AV: E=Sophos;i="6.09,192,1716274800"; d="scan'208";a="28279676" 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: qcuz5nqBTda/8P6pif7MJA== X-CSE-MsgGUID: 18qRtZecQyim/JfdIpSuNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,192,1716274800"; d="scan'208";a="47486295" 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:37 -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 03/10] Add a musttail generic attribute to the c-attribs table Date: Mon, 8 Jul 2024 09:55:55 -0700 Message-ID: <20240708170031.1621184-4-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.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 The actual handling is directly in the parser since the generic mechanism doesn't support statement attributes, but this gives basic error checking/detection on the attribute. gcc/c-family/ChangeLog: PR83324 * c-attribs.cc (handle_musttail_attribute): Add. * c-common.h (handle_musttail_attribute): Add. --- gcc/c-family/c-attribs.cc | 15 +++++++++++++++ gcc/c-family/c-common.h | 1 + 2 files changed, 16 insertions(+) diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index f9b229aba7fc..5adc7b775eaf 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -340,6 +340,8 @@ const struct attribute_spec c_common_gnu_attributes[] = { "common", 0, 0, true, false, false, false, handle_common_attribute, attr_common_exclusions }, + { "musttail", 0, 0, false, false, false, + false, handle_musttail_attribute, NULL }, /* FIXME: logically, noreturn attributes should be listed as "false, true, true" and apply to function types. But implementing this would require all the places in the compiler that use TREE_THIS_VOLATILE @@ -1222,6 +1224,19 @@ handle_common_attribute (tree *node, tree name, tree ARG_UNUSED (args), return NULL_TREE; } +/* Handle a "musttail" attribute; arguments as in + struct attribute_spec.handler. */ + +tree +handle_musttail_attribute (tree ARG_UNUSED (*node), tree name, tree ARG_UNUSED (args), + int ARG_UNUSED (flags), bool *no_add_attrs) +{ + /* Currently only a statement attribute, handled directly in parser. */ + warning (OPT_Wattributes, "%qE attribute ignored", name); + *no_add_attrs = true; + return NULL_TREE; +} + /* Handle a "noreturn" attribute; arguments as in struct attribute_spec.handler. */ diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 48c89b603bcd..e84c9c47513b 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1643,6 +1643,7 @@ extern tree find_tm_attribute (tree); extern const struct attribute_spec::exclusions attr_cold_hot_exclusions[]; extern const struct attribute_spec::exclusions attr_noreturn_exclusions[]; extern tree handle_noreturn_attribute (tree *, tree, tree, int, bool *); +extern tree handle_musttail_attribute (tree *, tree, tree, int, bool *); extern bool has_attribute (location_t, tree, tree, tree (*)(tree)); extern tree build_attr_access_from_parms (tree, bool);