On 7/9/21 2:18 PM, Iain Sandoe wrote:
Hi,

The mechanism used to date for uniquing the coroutine helper
functions (actor, destroy) was over-complicating things and
leading to the noted PR and also difficulties in setting
breakpoints on these functions (so this will help PR99215 as
well).  The revised mangling matches the form used by clang.

OK for master & backports?
thanks
Iain

Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>

PR c++/95520 - [coroutines] __builtin_FUNCTION() returns mangled .actor instead 
of original function name

        PR c++/95520

gcc/cp/ChangeLog:

        * coroutines.cc (act_des_fn): Adjust coroutine
        helper function name mangling.

gcc/testsuite/ChangeLog:

        * g++.dg/coroutines/pr95520.C: New test.
---
  gcc/cp/coroutines.cc                      | 14 +++++++++--
  gcc/testsuite/g++.dg/coroutines/pr95520.C | 29 +++++++++++++++++++++++
  2 files changed, 41 insertions(+), 2 deletions(-)
  create mode 100644 gcc/testsuite/g++.dg/coroutines/pr95520.C

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 54ffdc8d062..1a3ab58e044 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -3985,9 +3985,19 @@ register_local_var_uses (tree *stmt, int *do_subtree, 
void *d)
  static tree
  act_des_fn (tree orig, tree fn_type, tree coro_frame_ptr, const char* name)
  {
-  tree fn_name = get_fn_local_identifier (orig, name);
+  tree fn_name;
    location_t loc = DECL_SOURCE_LOCATION (orig);
-  tree fn = build_lang_decl (FUNCTION_DECL, fn_name, fn_type);
+  tree fn = build_lang_decl (FUNCTION_DECL, DECL_NAME (orig), fn_type);
+  if (tree da_name = DECL_ASSEMBLER_NAME (orig))
+    {
+      char *buf = xasprintf ("%s.%s", IDENTIFIER_POINTER (da_name), name);
+      fn_name = get_identifier (buf);
+      free (buf);
+    }
+  else
+    fn_name = get_fn_local_identifier (orig, name);

How about handling this in write_encoding, along the lines of the devel/c++-contracts branch?

Speaking of which, I wonder if you also want to do something similar to what I did there to put the ramp/actor/destroyer functions into into the same comdat group.

Jason

Reply via email to