aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorArsen Arsenović <arsen@aarsen.me>2024-09-05 19:53:07 +0200
committerArsen Arsenović <arsen@gcc.gnu.org>2024-12-10 16:43:39 +0100
commitfcdc0d8963adfa99315a7895b5685ac102182cdf (patch)
tree0c3f1b03f258450f5d63493b5b48a7208fe49a02 /gcc/c-family
parentc628def52c87b40b6270618252488bcd731e1843 (diff)
downloadgcc-fcdc0d8963adfa99315a7895b5685ac102182cdf.zip
gcc-fcdc0d8963adfa99315a7895b5685ac102182cdf.tar.gz
gcc-fcdc0d8963adfa99315a7895b5685ac102182cdf.tar.bz2
c++: Implement a coroutine language debug dump
This provides to people working on coroutines, as well as writing tests for coroutines, a way to have insight into the results and inputs of the coroutine transformation passes, which is quite essential to understanding what happens in the coroutine transformation. Currently, the information dumped is the pre-transform function (which is not otherwise available), the generated ramp function, the generated frame type, the transformed actor/resumer, and the destroyer stub. While debugging this, I've also encountered a minor bug in c-pretty-print.cc, where it tried to check DECL_REGISTER of DECLs that did not support it. I've added a check for that. Similary, I found one in pp_cxx_template_parameter, where TREE_TYPE was called on the list cell the template parameter was in rather than on the parameter itself. I've fixed that. And, lastly, there appeared to be no way to pretty-print a FIELD_DECL, so I added support to cxx_pretty_printer::declaration for it (by reusing the VAR_DECL path). Co-authored-by: Iain Sandoe <iain@sandoe.co.uk> gcc/c-family/ChangeLog: * c-pretty-print.cc (c_pretty_printer::storage_class_specifier): Check that we're looking at a PARM_DECL or VAR_DECL before looking at DECL_REGISTER. gcc/cp/ChangeLog: * coroutines.cc (dump_record_fields): New helper. Iterates a RECORD_TYPEs TYPE_FIELDS and pretty-prints them. (dmp_str): New. The lang-coro dump stream. (coro_dump_id): New. ID of the lang-coro dump. (coro_dump_flags): New. Flags passed to the lang-coro dump. (coro_maybe_dump_initial_function): New helper. Prints, if dumping is enabled, the fndecl passed to it as the original function. (coro_maybe_dump_ramp): New. Prints the ramp function passed to it, if dumping is enabled. (coro_maybe_dump_transformed_functions): New. (cp_coroutine_transform::apply_transforms): Initialize the lang-coro dump. Call coro_maybe_dump_initial_function on the original function, as well as coro_maybe_dump_ramp, after the transformation into the ramp is finished. (cp_coroutine_transform::finish_transforms): Call coro_maybe_dump_transformed_functions on the built actor and destroy. * cp-objcp-common.cc (cp_register_dumps): Register the coroutine dump. * cp-tree.h (coro_dump_id): Declare as extern. * cxx-pretty-print.cc (pp_cxx_template_parameter): Don't call TREE_TYPE on a TREE_LIST cell. (cxx_pretty_printer::declaration): Handle FIELD_DECL similar to VAR_DECL. gcc/ChangeLog: * dumpfile.cc (FIRST_ME_AUTO_NUMBERED_DUMP): Bump to 6 for sake of the coroutine dump.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-pretty-print.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc
index b772d8d..c48336f 100644
--- a/gcc/c-family/c-pretty-print.cc
+++ b/gcc/c-family/c-pretty-print.cc
@@ -753,7 +753,8 @@ c_pretty_printer::storage_class_specifier (tree t)
pp_c_ws_string (this, "typedef");
else if (DECL_P (t))
{
- if (DECL_REGISTER (t))
+ if ((TREE_CODE (t) == PARM_DECL || VAR_P (t))
+ && DECL_REGISTER (t))
pp_c_ws_string (this, "register");
else if (TREE_STATIC (t) && VAR_P (t))
pp_c_ws_string (this, "static");