From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by sourceware.org (Postfix) with ESMTPS id 07F4F3858D35 for ; Tue, 14 May 2024 17:24:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07F4F3858D35 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 07F4F3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715707456; cv=none; b=vYxIdk0ceXtBnKyd4R66lJ0DH6Ggm2I4fRKWpXOfFww97gL6gnKGUtXBkft5DhgtABL6GlO48makbDQlWFxKdCTeEvRg1mdPbJUETBG8EruG5Fscm/Fhuo7v2HIAWd/kk2Ih2xsiko5ht1PCWPe77MeLB6FB7a1ucIu7U3MmnnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715707456; c=relaxed/simple; bh=Emu/gecTnq5LapMf9HgLAIlOSH5uEtSLKoFUjtiG1Zk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=pEqU7cohSphx3vy4n/0ytMFVh+ebirtNWAqPVEOu12BfS6/md1Sx1FmZDCzXx7uYF90DyWG6YZp2ySUea5fTyM4bwl+R1lgBVKCWdZ7YcpKpFjGktjwb3/smt7rntYr2ADZvmBcxNrNAysszM53NNvEZObLWPLr7qAdY1CNyneg= 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=1715707455; x=1747243455; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Emu/gecTnq5LapMf9HgLAIlOSH5uEtSLKoFUjtiG1Zk=; b=hVhyZUVqA+nsi/MsMio1ad7oqWQrsf4fIHC/XqqW4CICswDbe9cQp9SV +yymPiv+tADPYtyV7IiE68dKHH81rFR31aHHJzcZuC6f7JxeMZh9tSRsY t+h5magBqLeIjHmYtJkmCpijaOi+GFNXSF+AeC7OEZNZ7mIQr6KWMC+tW MpGCpzEJbpKBOSgN4D39jOrtJuLKpWOM4lPSe+skov7I9ZmsgRXIliRpE oXXlC4gelNzULx+zD6ab4gnWBT8/UvDGokalmQSIGqqvdFscmaS96xciQ t+V3vJe8RYq1pBMsa6GvdkEOdgoSWoiDwicuNSsP6si3NlNqIvTlLVTbr w==; X-CSE-ConnectionGUID: 8LSqaVDER/mIVCXdgLPK9w== X-CSE-MsgGUID: rhWzrOmTTrOlNUV4mOwKwg== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="15497124" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="15497124" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 10:24:14 -0700 X-CSE-ConnectionGUID: qWfOvt86QxCIu3qAzMkLtA== X-CSE-MsgGUID: fBL7PX5ITfOd1gaHrc8BMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="68214859" Received: from tassilo.jf.intel.com (HELO tassilo) ([10.54.38.190]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 10:24:14 -0700 Date: Tue, 14 May 2024 10:24:13 -0700 From: Andi Kleen To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH v5 2/5] C++: Support clang compatible [[musttail]] (PR83324) Message-ID: References: <20240505181458.2903045-1-ak@linux.intel.com> <20240505181458.2903045-2-ak@linux.intel.com> <13a46de1-6551-4ff4-abac-2269e587d857@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13a46de1-6551-4ff4-abac-2269e587d857@redhat.com> X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 List-Id: Hi Jason, On Mon, May 06, 2024 at 11:02:20PM -0400, Jason Merrill wrote: > > @@ -30189,7 +30207,7 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns) > > /* Maybe we don't expect to see any arguments for this attribute. */ > > const attribute_spec *as > > = lookup_attribute_spec (TREE_PURPOSE (attribute)); > > - if (as && as->max_length == 0) > > + if ((as && as->max_length == 0) || is_attribute_p ("musttail", attr_id)) > > I'd prefer to add an attribute to the table, rather than special-case it > here; apart from consistency, it seems likely that someone will later want > to apply it to a function. Just to clarify. I can add it to the table, but it would be a nop there for now because the table is not used for statement attributes by the current parser. > > You need a template testcase; I expect it doesn't work in templates with the > current patch. It's probably enough to copy it in tsubst_expr where we > currently propagate CALL_EXPR_OPERATOR_SYNTAX. I tried it with the appended test case, everything seems to work without changes. Does it cover the cases you were concerned about? > > You also need a testcase where the function returns a class; in that case > the call will often appear as AGGR_INIT_EXPR rather than CALL_EXPR, so > you'll need to handle that as well. And see the places that copy flags like > CALL_EXPR_OPERATOR_SYNTAX between CALL_EXPR and AGGR_INIT_EXPR. Dito. -Andi /* { dg-do compile { target { tail_call } } } */ /* { dg-options "-O2" } */ /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */ class Foo { public: int a, b; Foo(int a, int b) : a(a), b(b) {} }; Foo __attribute__((noinline,noclone,noipa)) callee (int i) { return Foo(i, i+1); } Foo __attribute__((noinline,noclone,noipa)) caller (int i) { [[gnu::musttail]] return callee (i + 1); } template T __attribute__((noinline,noclone,noipa)) foo (T i) { return i + 1; } int caller2 (int k) { [[gnu::musttail]] return foo(1); } template T caller3 (T v) { [[gnu::musttail]] return foo(v); } int call3(int i) { [[gnu::musttail]] return caller3(i + 1); } class Bar { int a; public: Bar(int a) : a(a) {} Bar operator+(Bar o) { return Bar(a + o.a); } }; Bar caller3 (Bar k) { [[gnu::musttail]] return caller3(Bar(99)); }