aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2019-12-03 13:09:29 +0000
committerIain Sandoe <iain@sandoe.co.uk>2019-12-03 13:09:29 +0000
commit075cd8afb545925ecc0d88c114f33da6353a409c (patch)
tree7a0bdc9643253306c8e4d64954f2312bc286708c
parent9d5bec7646fdc120087e39ba6ac01b5c299bf8aa (diff)
c++coroutines - Address review comments, make a more specific pass gate.
To avoid scanning every function for coroutine state machine IFNs, we allocate and set a bit in the function structure for coroutines. This together with the enable flag, can be tested to skip the scan for all other functions. 2019-12-03 Iain Sandoe <iain@sandoe.co.uk> gcc/ * coroutine-passes.cc (gate): Check for coroutine components in addition to the coroutine enable flag before executing the IFN lowering pass. * function.h (struct function): Allocate a bit to indicate that the function is a coroutine component. gcc/cp/ * decl.c (emit_coro_helper): Set coroutine component bit when needed. (finish_function): Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/c++-coroutines@278936 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--ChangeLog.coroutines14
-rw-r--r--gcc/coroutine-passes.cc5
-rw-r--r--gcc/cp/decl.c5
-rw-r--r--gcc/function.h3
4 files changed, 26 insertions, 1 deletions
diff --git a/ChangeLog.coroutines b/ChangeLog.coroutines
index 16fb1bf359d..dc3d8d45f81 100644
--- a/ChangeLog.coroutines
+++ b/ChangeLog.coroutines
@@ -1,3 +1,17 @@
+2019-12-03 Iain Sandoe <iain@sandoe.co.uk>
+
+ gcc/
+ * coroutine-passes.cc (gate): Check for coroutine components in
+ addition to the coroutine enable flag before executing the IFN
+ lowering pass.
+ * function.h (struct function): Allocate a bit to indicate that
+ the function is a coroutine component.
+
+ gcc/cp/
+ * decl.c (emit_coro_helper): Set coroutine component bit when
+ needed.
+ (finish_function): Likewise.
+
2019-12-02 Iain Sandoe <iain@sandoe.co.uk>
Merge trunk r278894.
diff --git a/gcc/coroutine-passes.cc b/gcc/coroutine-passes.cc
index c995d676384..623e49f95bc 100644
--- a/gcc/coroutine-passes.cc
+++ b/gcc/coroutine-passes.cc
@@ -520,7 +520,10 @@ public:
{}
/* opt_pass methods: */
- virtual bool gate (function *) { return flag_coroutines; };
+ virtual bool gate (function *f)
+ {
+ return flag_coroutines && f->coroutine_component;
+ }
virtual unsigned int execute (function *f ATTRIBUTE_UNUSED)
{
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 70345eab2ed..d8e647e7c20 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -16705,6 +16705,8 @@ emit_coro_helper (tree helper)
cp_fold_function (helper);
DECL_CONTEXT (DECL_RESULT (helper)) = helper;
BLOCK_SUPERCONTEXT (DECL_INITIAL (helper)) = helper;
+ /* We should handle coroutine IFNs in middle end lowering. */
+ cfun->coroutine_component = true;
cp_genericize (helper);
expand_or_defer_fn (helper);
}
@@ -16760,6 +16762,9 @@ finish_function (bool inline_p)
return fndecl;
}
+ /* We should handle coroutine IFNs in middle end lowering. */
+ cfun->coroutine_component = true;
+
if (use_eh_spec_block (fndecl))
finish_eh_spec_block (TYPE_RAISES_EXCEPTIONS
(TREE_TYPE (fndecl)),
diff --git a/gcc/function.h b/gcc/function.h
index beb5c7d0cba..37a316f9840 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -418,6 +418,9 @@ struct GTY(()) function {
/* Set when the function was compiled with generation of debug
(begin stmt, inline entry, ...) markers enabled. */
unsigned int debug_nonbind_markers : 1;
+
+ /* Set if this is a coroutine-related function. */
+ unsigned int coroutine_component : 1;
};
/* Add the decl D to the local_decls list of FUN. */