public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] coroutines: Fix ICEs with capability comparisons
@ 2022-05-20 12:34 Alex Coplan
  0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2022-05-20 12:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:68c1db55253b24240615350f80479bc20bc6cc03

commit 68c1db55253b24240615350f80479bc20bc6cc03
Author: Alex Coplan <alex.coplan@arm.com>
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))
 	{


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-20 12:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 12:34 [gcc(refs/vendors/ARM/heads/morello)] coroutines: Fix ICEs with capability comparisons Alex Coplan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).