From patchwork Tue Mar 9 09:51:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1449614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=d9KH5Pqo; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dvr8s4zdXz9sCD for ; Tue, 9 Mar 2021 20:52:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F9EF382E80E; Tue, 9 Mar 2021 09:52:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F9EF382E80E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1615283531; bh=7W/EJQ8PHwfjQH80Pw8bI3HhLr2EakdFbu1v3hqAN/I=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=d9KH5PqoZ7t50QcUkqShO3B/2A/ciNvTS94z94WREmN1dfZ14buG22mtYPUXfZxGx HEG5b8lwHO3ANOJYdzytpF/3gKuFcn5Cwce4qcanlyFuza0+7hyaWCzhqZ7UCdSUqU wtb5R/z6fHzCLPptu3dRy67cG3QGLFnTjyxgnyMA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 2EFC2383F84F for ; Tue, 9 Mar 2021 09:52:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2EFC2383F84F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-W5dWqS80OqG08a_zFcA83Q-1; Tue, 09 Mar 2021 04:52:04 -0500 X-MC-Unique: W5dWqS80OqG08a_zFcA83Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1DB1926865; Tue, 9 Mar 2021 09:52:03 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-238.ams2.redhat.com [10.36.113.238]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD1F019814; Tue, 9 Mar 2021 09:52:02 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1299q0h61835873 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 9 Mar 2021 10:52:00 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1299pw1D1835872; Tue, 9 Mar 2021 10:51:58 +0100 Date: Tue, 9 Mar 2021 10:51:58 +0100 To: Nathan Sidwell , Iain Sandoe Subject: [PATCH] c++: Fix coroutines on targetm.cxx.cdtor_return_this targets [PR99459] Message-ID: <20210309095158.GL745611@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! The r11-7528 build_co_await changes broke coroutines on arm*-linux-gnuabi, 2780 ^FAIL.*coroutines/ in total. The problem is that arm is targetm.cxx.cdtor_return_this target where both ctors and dtors in the ABI return this pointer rather than void, and build_new_method_call_1 does: else if (call != error_mark_node && DECL_DESTRUCTOR_P (cand->fn) && !VOID_TYPE_P (TREE_TYPE (call))) /* An explicit call of the form "x->~X()" has type "void". However, on platforms where destructors return "this" (i.e., those where targetm.cxx.cdtor_returns_this is true), such calls will appear to have a return value of pointer type to the low-level call machinery. We do not want to change the low-level machinery, since we want to be able to optimize "delete f()" on such platforms as "operator delete(~X(f()))" (rather than generating "t = f(), ~X(t), operator delete (t)"). */ call = build_nop (void_type_node, call); The new code in build_co_await relies on build_special_member_call returned expression being a CALL_EXPR, but due to the build_nop in there it is a NOP_EXPR around the CALL_EXPR. It can't be stripped with STRIP_NOPS because void has different mode from the pointer mode. Bootstrapped/regtested on armv7hl-linux-gnueabi and x86_64-linux, ok for trunk? 2021-03-09 Jakub Jelinek PR c++/99459 * coroutines.cc (build_co_await): Look through NOP_EXPRs in build_special_member_call return value to find the CALL_EXPR. Jakub --- gcc/cp/coroutines.cc.jj 2021-03-05 21:51:48.671185716 +0100 +++ gcc/cp/coroutines.cc 2021-03-08 10:53:13.187959339 +0100 @@ -868,6 +868,8 @@ build_co_await (location_t loc, tree a, = build_special_member_call (a, complete_dtor_identifier, NULL, a_type, LOOKUP_NORMAL, tf_none); + if (dummy && CONVERT_EXPR_P (dummy)) + dummy = TREE_OPERAND (dummy, 0); dummy = dummy ? TREE_OPERAND (CALL_EXPR_FN (dummy), 0) : NULL_TREE; if (dummy && coro_diagnose_throwing_fn (dummy)) @@ -1031,6 +1033,8 @@ build_co_await (location_t loc, tree a, = build_special_member_call (e_proxy, complete_dtor_identifier, NULL, o_type, LOOKUP_NORMAL, tf_none); + if (dummy && CONVERT_EXPR_P (dummy)) + dummy = TREE_OPERAND (dummy, 0); dummy = dummy ? TREE_OPERAND (CALL_EXPR_FN (dummy), 0) : NULL_TREE; if (dummy && coro_diagnose_throwing_fn (dummy))