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.133.124]) by sourceware.org (Postfix) with ESMTPS id 6D9423857361 for ; Tue, 11 Oct 2022 23:19:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D9423857361 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665530346; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CZ/aA8XiqRfEtI/s/FET+S5eyN6NWRum/RIN2h+LSHY=; b=IH5z1WaWmSNZBo+C76q0VH4CVqIYl1vGf+hJTh3HPz4nSxIk0Y/9XmFJt/egXh5AfoKLWW dDw588bVZnvxuACeEWRVWsyTZX899ldwdeIj0c4+GH6Q4tl+3FMFmAFICby8k+6R6G9VT/ EihnrZv1Q5Oc9Jf4pBxk+wXoRI8SIb8= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-572-FKjaZy5eOuinqqvuMq8O0A-1; Tue, 11 Oct 2022 19:19:04 -0400 X-MC-Unique: FKjaZy5eOuinqqvuMq8O0A-1 Received: by mail-qk1-f198.google.com with SMTP id o13-20020a05620a2a0d00b006cf9085682dso12740312qkp.7 for ; Tue, 11 Oct 2022 16:19:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CZ/aA8XiqRfEtI/s/FET+S5eyN6NWRum/RIN2h+LSHY=; b=oJ3X33iLV4u2XvN8ZZMU7pFDCi5XaOUdfNrszoQ6D0z/A4FlzPU4cEEyDuNgZuIqgd Omob2Q2lRvKwwrOEHO37zCd0lruz3kGWuig2ghAl1N4scv1h5dreqfkGytOjrTd/10Rg 81OnJ4taI76Y83SJszqvkIBtdZQ6Z0thj89RexQq+9+5+z8MtvhaxJpIb47PsvOhJn/w P8iqnEI6u2X2qPao13OHA54+f8EpYAGyYcEBSJYQr1+6SHKv+k/ctBbbwu0RAkhYimbQ xQUMOVPKlYMl/zxOql6DaQZJZWERJIw1dp6bFrLO4wPxrXxoIjYt4+YUpUlh5lEjRC2x 3XiA== X-Gm-Message-State: ACrzQf34WGHklMCk0oBq2368IaZcMvmzkYVEEMADJyXW9xTJyXMWz6Ak GbBigzZFdH01U58Qxx5Zt7sgiqfG7jk7PB/yS/J3Q6ykEeOYufxEUDO+tQtnkrLQx8NiHNt08z4 dw4tP9HRcE818i2jy+w== X-Received: by 2002:a05:6214:c88:b0:4b1:7083:2fca with SMTP id r8-20020a0562140c8800b004b170832fcamr21462557qvr.3.1665530344101; Tue, 11 Oct 2022 16:19:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM64uDbe/VtXHmnQfY0ZsVicEoHV27QKD7e0w9Hcl2aVw+I4iCNY9g2NdnKXRirZtkeI0k6HhA== X-Received: by 2002:a05:6214:c88:b0:4b1:7083:2fca with SMTP id r8-20020a0562140c8800b004b170832fcamr21462538qvr.3.1665530343777; Tue, 11 Oct 2022 16:19:03 -0700 (PDT) Received: from [192.168.1.101] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id j1-20020a05620a410100b006cfaee39ccesm14475162qko.114.2022.10.11.16.19.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Oct 2022 16:19:03 -0700 (PDT) Message-ID: Date: Tue, 11 Oct 2022 19:19:02 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH] coroutines: Use cp_build_init_expr consistently. To: Iain Sandoe Cc: GCC Patches References: <20221011215831.67154-1-iain@sandoe.co.uk> <44bcfe36-d570-c8d4-7980-4e8b2a2aac60@redhat.com> <9403FB3B-D300-4F62-B5D8-8BA83BB66F42@sandoe.co.uk> From: Jason Merrill In-Reply-To: <9403FB3B-D300-4F62-B5D8-8BA83BB66F42@sandoe.co.uk> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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: On 10/11/22 18:17, Iain Sandoe wrote: > Hi Jason > >> On 11 Oct 2022, at 23:06, Jason Merrill wrote: >> >> On 10/11/22 17:58, Iain Sandoe wrote: >>> Tested on x86_64-darwin19, OK for master? >>> thanks >>> Iain >>> -- >8 -- >>> Now we have the TARGET_EXPR_ELIDING_P flag, it is important to ensure it >>> is set properly on target exprs. The code here has a mixture of APIs used >>> to build inits. This patch changes that to use cp_build_init_expr() where >>> possible, since that handles setting the flag. >> >> Hmm, I wouldn't expect this to be necessary, since cp_build_modify_expr calls cp_build_init_expr for INIT_EXPR. > > It seems that path is only taken if the init is a CONSTRUCTOR. If it's not a CONSTRUCTOR it builds a constructor call, which should end up having the same effect. Certainly cp_build_init_expr is simpler if it works, so the patch is OK, but if it's necessary that indicates a bug that should be fixed. >> Perhaps the similarity of the function names is a trap... > > not sure exactly what trap you mean. The names are close, but cp_build_modify_expr is a lot more complicated; it handles conversions and overloaded operators. > It seems that on my local set of additional tests (for some of the open prs) there are some > progressions from this change, I will have to track down which change is the cause. > > thanks > Iain > >> >>> --- >>> gcc/cp/coroutines.cc | 25 ++++++++----------------- >>> 1 file changed, 8 insertions(+), 17 deletions(-) >>> diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc >>> index 01a3e831ee5..20d309445eb 100644 >>> --- a/gcc/cp/coroutines.cc >>> +++ b/gcc/cp/coroutines.cc >>> @@ -1025,8 +1025,7 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind) >>> else >>> { >>> e_proxy = get_awaitable_var (suspend_kind, o_type); >>> - o = cp_build_modify_expr (loc, e_proxy, INIT_EXPR, o, >>> - tf_warning_or_error); >>> + o = cp_build_init_expr (loc, e_proxy, o); >>> } >>> /* I suppose we could check that this is contextually convertible to bool. */ >>> @@ -2889,8 +2888,7 @@ flatten_await_stmt (var_nest_node *n, hash_set *promoted, >>> gcc_checking_assert (!already_present); >>> tree inner = TREE_OPERAND (init, 1); >>> gcc_checking_assert (TREE_CODE (inner) != COND_EXPR); >>> - init = cp_build_modify_expr (input_location, var, INIT_EXPR, init, >>> - tf_warning_or_error); >>> + init = cp_build_init_expr (var, init); >>> /* Simplify for the case that we have an init containing the temp >>> alone. */ >>> if (t == n->init && n->var == NULL_TREE) >>> @@ -3656,8 +3654,7 @@ await_statement_walker (tree *stmt, int *do_subtree, void *d) >>> if (TREE_CODE (cond_inner) == CLEANUP_POINT_EXPR) >>> cond_inner = TREE_OPERAND (cond_inner, 0); >>> location_t sloc = EXPR_LOCATION (SWITCH_STMT_COND (sw_stmt)); >>> - tree new_s = cp_build_init_expr (sloc, newvar, >>> - cond_inner); >>> + tree new_s = cp_build_init_expr (sloc, newvar, cond_inner); >>> finish_expr_stmt (new_s); >>> SWITCH_STMT_COND (sw_stmt) = newvar; >>> /* Now add the switch statement with the condition re- >>> @@ -4902,9 +4899,8 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) >>> if (flag_exceptions) >>> { >>> /* This var is now live. */ >>> - r = build_modify_expr (fn_start, parm.guard_var, >>> - boolean_type_node, INIT_EXPR, fn_start, >>> - boolean_true_node, boolean_type_node); >>> + r = cp_build_init_expr (fn_start, parm.guard_var, >>> + boolean_true_node); >>> finish_expr_stmt (r); >>> } >>> } >>> @@ -4948,9 +4944,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) >>> r = coro_build_cvt_void_expr_stmt (r, fn_start); >>> finish_expr_stmt (r); >>> - r = build_modify_expr (fn_start, coro_promise_live, boolean_type_node, >>> - INIT_EXPR, fn_start, boolean_true_node, >>> - boolean_type_node); >>> + r = cp_build_init_expr (fn_start, coro_promise_live, boolean_true_node); >>> finish_expr_stmt (r); >>> promise_dtor >>> @@ -5031,8 +5025,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) >>> NULL_TREE); >>> add_decl_expr (gro); >>> gro_bind_vars = gro; >>> - r = cp_build_modify_expr (input_location, gro, INIT_EXPR, get_ro, >>> - tf_warning_or_error); >>> + r = cp_build_init_expr (gro, get_ro); >>> /* The constructed object might require a cleanup. */ >>> if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (gro_type)) >>> { >>> @@ -5053,9 +5046,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) >>> cleanup. */ >>> if (gro_ret_dtor) >>> { >>> - r = build_modify_expr (fn_start, coro_gro_live, boolean_type_node, >>> - INIT_EXPR, fn_start, boolean_true_node, >>> - boolean_type_node); >>> + r = cp_build_init_expr (fn_start, coro_gro_live, boolean_true_node); >>> finish_expr_stmt (r); >>> } >>> /* Initialize the resume_idx_var to 0, meaning "not started". */ >> >