From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7810) id 75FA53857374; Fri, 20 May 2022 12:34:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75FA53857374 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alex Coplan To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] coroutines: Fix ICEs with capability comparisons X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: d7f8b9c884e6543aefe40c13fdd19f4caa997026 X-Git-Newrev: 68c1db55253b24240615350f80479bc20bc6cc03 Message-Id: <20220520123406.75FA53857374@sourceware.org> Date: Fri, 20 May 2022 12:34:06 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2022 12:34:06 -0000 https://gcc.gnu.org/g:68c1db55253b24240615350f80479bc20bc6cc03 commit 68c1db55253b24240615350f80479bc20bc6cc03 Author: Alex Coplan Date: Wed Mar 16 17:10:03 2022 +0000 coroutines: Fix ICEs with capability comparisons When lowering __builtin_coro_done we were emitting a direct comparison of capabilities: this change uses the new gimple_drop_capability to compare address values instead. Similarly, we fix up morph_fn_to_coro to avoid performing invalid operations on capabilities. gcc/ChangeLog: * coroutine-passes.cc (lower_coro_builtin): Fix null check to compare address values. gcc/cp/ChangeLog: * coroutines.cc (morph_fn_to_coro): Fix capability comparison. Diff: --- gcc/coroutine-passes.cc | 7 ++++++- gcc/cp/coroutines.cc | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gcc/coroutine-passes.cc b/gcc/coroutine-passes.cc index d032a392ce6..325c5e75f27 100644 --- a/gcc/coroutine-passes.cc +++ b/gcc/coroutine-passes.cc @@ -164,8 +164,13 @@ lower_coro_builtin (gimple_stmt_iterator *gsi, bool *handled_ops_p, tree d_ptr_tmp = make_ssa_name (ptr_type_node); gassign *get_dptr = gimple_build_assign (d_ptr_tmp, indirect); gsi_insert_before (gsi, get_dptr, GSI_SAME_STMT); + + gimple_seq seq = NULL; + d_ptr_tmp = gimple_drop_capability (&seq, d_ptr_tmp); + gsi_insert_seq_before (gsi, seq, GSI_SAME_STMT); + tree done = fold_build2 (EQ_EXPR, boolean_type_node, d_ptr_tmp, - null_pointer_node); + fold_drop_capability (null_pointer_node)); gassign *get_res = gimple_build_assign (lhs, done); gsi_replace (gsi, get_res, true); *handled_ops_p = true; diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index e89a71de1a1..bc7086253b5 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -4356,8 +4356,11 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer) gcc_checking_assert (same_type_p (fn_return_type, TREE_TYPE (grooaf))); tree if_stmt = begin_if_stmt (); - tree cond = build1 (CONVERT_EXPR, coro_frame_ptr, integer_zero_node); - cond = build2 (EQ_EXPR, boolean_type_node, coro_fp, cond); + tree coro_fp_addr = drop_capability (coro_fp); + tree cond = build2 (EQ_EXPR, + boolean_type_node, + coro_fp_addr, + build_zero_cst (TREE_TYPE (coro_fp_addr))); finish_if_stmt_cond (cond, if_stmt); if (VOID_TYPE_P (fn_return_type)) {