From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D11CC3884523 for ; Mon, 3 Jun 2024 15:44:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D11CC3884523 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D11CC3884523 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717429498; cv=none; b=SF6KCYhxGZaxvcnc8yCZaDlqvbW4MMUH4h03xbVOjtzuZDwysGouvl+JBJEy/Fb25myfUJnUEdIWocA2dNTpWidw5/IvuCx+Q3zYu3R2qmTWhNaKcZt4Nv3H2ZCfDuD2SCQYRMUcWSVZ20NkKnrPoe2zY6/Ea8Sv3WTWjvg95mI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717429498; c=relaxed/simple; bh=DRoC0qA1WpX8CTMMmtx/qwPkVuUTP7+6PB+n7rk0XKE=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=qr+3N+bA6diUaD6C+wC9GI0mwMfgzNLLfmF/HtH0Exx6f6YeS3VlLeMdpL5Q9ehp+8s7wGGT+1brJAOs1joGuV9N6uwD6srKIoGbzth2J80FCmnJBHiDsVbUYRtLaqFqZn4dwFZn2j5CK+99b1RS8Bs5Kydc3b8iuNjIkVFTLPU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717429496; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=OotA3L8Zhc2qmkl1WubkaiCBxZOkwNSamSMfcRxGGgk=; b=J/zaChqK4c2H1Ym9D7YdNcD+ZnuIeWFQdpHLyGBT3cNheplxA7BUU5OzIY3F6TCoKrzwdp lbbfOEPb77O5HtajWak70U+bJPT12MEsKrxHCW48fTUDexwyew8QjXr/oo3CioJv5ircNB L+iQs4I85BGxvTl750TJTT+c/W6GSew= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-abFlJwJtOdGsre73BJfUsA-1; Mon, 03 Jun 2024 11:44:53 -0400 X-MC-Unique: abFlJwJtOdGsre73BJfUsA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0D45800CB1; Mon, 3 Jun 2024 15:44:51 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E719404F585; Mon, 3 Jun 2024 15:44:51 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 453FinsA139486 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 3 Jun 2024 17:44:49 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 453FimTS139485; Mon, 3 Jun 2024 17:44:48 +0200 Date: Mon, 3 Jun 2024 17:44:48 +0200 From: Jakub Jelinek To: Andi Kleen Cc: Jason Merrill , gcc-patches@gcc.gnu.org, richard.guenther@gmail.com, nathan@acm.org, josmyers@redhat.com, richard.sandiford@arm.com Subject: Re: [PATCH v7 4/9] C++: Support clang compatible [[musttail]] (PR83324) Message-ID: Reply-To: Jakub Jelinek References: <20240602172205.2151579-1-ak@linux.intel.com> <20240602172205.2151579-5-ak@linux.intel.com> <17a8e9ad-64a1-41bb-8ebc-70305e3fa2f6@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: On Mon, Jun 03, 2024 at 08:33:52AM -0700, Andi Kleen wrote: > On Mon, Jun 03, 2024 at 10:42:20AM -0400, Jason Merrill wrote: > > > @@ -30316,7 +30348,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)) > > > > This shouldn't be necessary with the attribute in the c-attribs table, > > right? This patch is OK without this hunk and with the comment tweak above. > > Yes I will remove it. Also the hunk above can be simplified, we don't > need the extra case anymore. > > But unfortunately there's another problem (sorry I missed that earlier > but the Linaro bot pointed it out again): > > This hunk: > > @@ -21085,12 +21085,14 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) > bool op = CALL_EXPR_OPERATOR_SYNTAX (t); > bool ord = CALL_EXPR_ORDERED_ARGS (t); > bool rev = CALL_EXPR_REVERSE_ARGS (t); > - if (op || ord || rev) > + bool mtc = CALL_EXPR_MUST_TAIL_CALL (t); > + if (op || ord || rev || mtc) > if (tree call = extract_call_expr (ret)) > { > CALL_EXPR_OPERATOR_SYNTAX (call) = op; > CALL_EXPR_ORDERED_ARGS (call) = ord; > CALL_EXPR_REVERSE_ARGS (call) = rev; > + CALL_EXPR_MUST_TAIL_CALL (call) = mtc; > } The difference is that CALL_EXPR_MUST_TAIL_CALL is defined as: #define CALL_EXPR_MUST_TAIL_CALL(NODE) \ (CALL_EXPR_CHECK (NODE)->base.static_flag) while the others like: #define CALL_EXPR_ORDERED_ARGS(NODE) \ TREE_LANG_FLAG_3 (CALL_OR_AGGR_INIT_CHECK (NODE)) where #define CALL_OR_AGGR_INIT_CHECK(NODE) \ TREE_CHECK2 ((NODE), CALL_EXPR, AGGR_INIT_EXPR) while #define CALL_EXPR_CHECK(t) TREE_CHECK (t, CALL_EXPR) (this one is defined in generated tree-check.h). So, while the CALL_EXPR_REVERSE_ARGS etc. can be used on either CALL_EXPR or AGGR_INIT_EXPR (the latter is a C++ specific tree code), CALL_EXPR_MUST_TAIL_CALL is allowed only on CALL_EXPR. AGGR_INIT_EXPR is used for C++ constructor calls, so I think they really don't need such a flag, so you could do: bool mtc = (TREE_CODE (t) == CALL_EXPR ? CALL_EXPR_MUST_TAIL_CALL (t) : false); if (op || ord || rev || mtc) ... if (mtc) CALL_EXPR_MUST_TAIL_CALL (call) = 1; or something similar. Or you'd need to define a variant of the CALL_EXPR_MUST_TAIL_CALL macro for the C++ FE (as CALL_OR_AGGR_INIT_CHECK is C++ FE too) and use that in the FE and somehow assert it means the same thing as the middle-end flag except that it can be also used on AGGR_INIT_EXPR. Jakub