From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by sourceware.org (Postfix) with ESMTPS id 7D56C3842411 for ; Tue, 9 Mar 2021 13:01:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7D56C3842411 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x733.google.com with SMTP id 130so12774699qkh.11 for ; Tue, 09 Mar 2021 05:01:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=88MrSaztbyPylKdraSZTqFOscFgaVTpAMcVSkxVn3O8=; b=IMx7/U26QgZLzADGPj5JfFp4o856Fc9QONQe+xKVK6C0x/1xMOBvc9KEIpDQ3ozI8/ jeyHmewF3CIkFuc04Fu3RSgLfCE88ZCn8XIPV+hkfiEIlHYjTqjvjBjfnXbSQMfYJ/Pw Bs2CSusF13O08Kx8AV8dwD+PUjOZOlkdc+2LKI251q3r833WhWVKOZwG3K01eBNlUUjA 3I3fPDf8Yz2/HL+E31HPdx+zpPjywqxbUf3L7Mlo+HvKkEx1csR43UGz1cIp5g55Y7ut rH8/kfZ5SbmV7I7lLdYAviN1cJ7bDTkDbeSBtB5kNp3yAvzLRHDium2ZI82sR34NHGEw F+5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=88MrSaztbyPylKdraSZTqFOscFgaVTpAMcVSkxVn3O8=; b=OsB53UpOWA9I+0DJjoCwcjKOj3Ofyw23t+bJpLsDBu8GOFq042+qnIoUoKs8agNQCY EC9uby6wYK8zTB9UD6kDxejX2ys1q7UPKwF60vu7P+2/G66HFLVixdsoY4Mzutlm26Kd KVW4JUAfqfFpqP3qXGIFeAqJQhONw9Df7RQvzvKwGcAdK37Oso2FUb0IJgftTcXiJZzS BoMOJR9rD30H7d/xvdLeWZ8HB4f8h9O95yjfCfvpQUnO3PkXrOa14+d3kFRyfOIOFAIt vZIpWoyDWEl9YTVGVoGBmQjrw9BdInkqkQo9pYvw7Ahybs9eouHDRxOrAuLFi+K0FwLm 5tfg== X-Gm-Message-State: AOAM532YliDYgBm2Z+DN68iDxYeIMy/40Jpg0WLqFsO4Htw3kut/VpAc U7Pj8yfQ7zMVBcajSv2qLe8= X-Google-Smtp-Source: ABdhPJx4yr64HmBW2ssNHlblvDcI4u1rOe3dLjdYTGUfmhrN2oHthpvQs056GxWq0yZwsWoCt49iJg== X-Received: by 2002:a37:9f4e:: with SMTP id i75mr25347582qke.283.1615294888991; Tue, 09 Mar 2021 05:01:28 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:20fa:4917:cb8c:ae6c? ([2620:10d:c091:480::1:4909]) by smtp.googlemail.com with ESMTPSA id q65sm9777868qkb.51.2021.03.09.05.01.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Mar 2021 05:01:28 -0800 (PST) Sender: Nathan Sidwell Subject: Re: [PATCH] c++: Fix coroutines on targetm.cxx.cdtor_return_this targets [PR99459] To: Jakub Jelinek , Iain Sandoe Cc: gcc-patches@gcc.gnu.org References: <20210309095158.GL745611@tucnak> From: Nathan Sidwell Message-ID: <8f407ed8-7d7c-6fc2-f43d-eb9a06e37a68@acm.org> Date: Tue, 9 Mar 2021 08:01:26 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20210309095158.GL745611@tucnak> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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-List-Received-Date: Tue, 09 Mar 2021 13:01:31 -0000 On 3/9/21 4:51 AM, Jakub Jelinek wrote: > 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? thanks for digging into this. Looks good, but could you take the opportunity to rewrite the conditionals to a single if (dummy) { ... do the non-null things ... } ? > > 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. > > --- 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)) > > Jakub > -- Nathan Sidwell