public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] debug/110295 - mixed up early/late debug for member DIEs
       [not found] <10678.123061906202700891@us-mta-531.us.mimecast.lan>
@ 2023-06-19 17:18 ` Jason Merrill
  2023-06-20  7:01   ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2023-06-19 17:18 UTC (permalink / raw)
  To: Richard Biener, gcc-patches

On 6/19/23 06:15, Richard Biener wrote:
> When we process a scope typedef during early debug creation and
> we have already created a DIE for the type when the decl is
> TYPE_DECL_IS_STUB and this DIE is still in limbo we end up
> just re-parenting that type DIE instead of properly creating
> a DIE for the decl, eventually picking up the now completed
> type and creating DIEs for the members.  Instead this is currently
> defered to the second time we come here, when we annotate the
> DIEs with locations late where now the type DIE is no longer
> in limbo and we fall through doing the job for the decl.
> 
> The following makes sure we perform the necessary early tasks
> for this by continuing with the decl DIE creation after setting
> a parent for the limbo type DIE.
> 
> [LTO] Bootstrapped on x86_64-unknown-linux-gnu.
> 
> OK for trunk?
> 
> Thanks,
> Richard.
> 
> 	PR debug/110295
> 	* dwarf2out.cc (process_scope_var): Continue processing
> 	the decl after setting a parent in case the existing DIE
> 	was in limbo.
> 
> 	* g++.dg/debug/pr110295.C: New testcase.
> ---
>   gcc/dwarf2out.cc                      |  3 ++-
>   gcc/testsuite/g++.dg/debug/pr110295.C | 19 +++++++++++++++++++
>   2 files changed, 21 insertions(+), 1 deletion(-)
>   create mode 100644 gcc/testsuite/g++.dg/debug/pr110295.C
> 
> diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
> index d89ffa66847..e70c47cec8d 100644
> --- a/gcc/dwarf2out.cc
> +++ b/gcc/dwarf2out.cc
> @@ -26533,7 +26533,8 @@ process_scope_var (tree stmt, tree decl, tree origin, dw_die_ref context_die)
>   
>     if (die != NULL && die->die_parent == NULL)
>       add_child_die (context_die, die);

I wonder about reorganizing the function a bit to unify this parent 
setting with the one a bit below, which already falls through to 
gen_decl_die:

>       if (decl && DECL_P (decl))
>         {
>           die = lookup_decl_die (decl);
> 
>           /* Early created DIEs do not have a parent as the decls refer                                                             
>              to the function as DECL_CONTEXT rather than the BLOCK.  */
>           if (die && die->die_parent == NULL)
>             {
>               gcc_assert (in_lto_p);
>               add_child_die (context_die, die);
>             }
>         }

OK either way.

Jason


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] debug/110295 - mixed up early/late debug for member DIEs
  2023-06-19 17:18 ` [PATCH] debug/110295 - mixed up early/late debug for member DIEs Jason Merrill
@ 2023-06-20  7:01   ` Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2023-06-20  7:01 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

On Mon, 19 Jun 2023, Jason Merrill wrote:

> On 6/19/23 06:15, Richard Biener wrote:
> > When we process a scope typedef during early debug creation and
> > we have already created a DIE for the type when the decl is
> > TYPE_DECL_IS_STUB and this DIE is still in limbo we end up
> > just re-parenting that type DIE instead of properly creating
> > a DIE for the decl, eventually picking up the now completed
> > type and creating DIEs for the members.  Instead this is currently
> > defered to the second time we come here, when we annotate the
> > DIEs with locations late where now the type DIE is no longer
> > in limbo and we fall through doing the job for the decl.
> > 
> > The following makes sure we perform the necessary early tasks
> > for this by continuing with the decl DIE creation after setting
> > a parent for the limbo type DIE.
> > 
> > [LTO] Bootstrapped on x86_64-unknown-linux-gnu.
> > 
> > OK for trunk?
> > 
> > Thanks,
> > Richard.
> > 
> >  PR debug/110295
> >  * dwarf2out.cc (process_scope_var): Continue processing
> >  the decl after setting a parent in case the existing DIE
> >  was in limbo.
> > 
> > 	* g++.dg/debug/pr110295.C: New testcase.
> > ---
> >   gcc/dwarf2out.cc                      |  3 ++-
> >   gcc/testsuite/g++.dg/debug/pr110295.C | 19 +++++++++++++++++++
> >   2 files changed, 21 insertions(+), 1 deletion(-)
> >   create mode 100644 gcc/testsuite/g++.dg/debug/pr110295.C
> > 
> > diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
> > index d89ffa66847..e70c47cec8d 100644
> > --- a/gcc/dwarf2out.cc
> > +++ b/gcc/dwarf2out.cc
> > @@ -26533,7 +26533,8 @@ process_scope_var (tree stmt, tree decl, tree
> > origin, dw_die_ref context_die)
> >   
> >     if (die != NULL && die->die_parent == NULL)
> >       add_child_die (context_die, die);
> 
> I wonder about reorganizing the function a bit to unify this parent setting
> with the one a bit below, which already falls through to gen_decl_die:
> 
> >       if (decl && DECL_P (decl))
> >         {
> >           die = lookup_decl_die (decl);
> > 
> >           /* Early created DIEs do not have a parent as the decls refer
> >           to the function as DECL_CONTEXT rather than the BLOCK.  */
> >           if (die && die->die_parent == NULL)
> >             {
> >               gcc_assert (in_lto_p);
> >               add_child_die (context_die, die);
> >             }
> >         }

Unfortunately that one can pick a DIE for the decl while the former
also handles the stub case in which case it is a different DIE, the
one for the type.
 
> OK either way.

Pushed.

Thanks,
Richard.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] debug/110295 - mixed up early/late debug for member DIEs
@ 2023-06-19 10:15 Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2023-06-19 10:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason

When we process a scope typedef during early debug creation and
we have already created a DIE for the type when the decl is
TYPE_DECL_IS_STUB and this DIE is still in limbo we end up
just re-parenting that type DIE instead of properly creating
a DIE for the decl, eventually picking up the now completed
type and creating DIEs for the members.  Instead this is currently
defered to the second time we come here, when we annotate the
DIEs with locations late where now the type DIE is no longer
in limbo and we fall through doing the job for the decl.

The following makes sure we perform the necessary early tasks
for this by continuing with the decl DIE creation after setting
a parent for the limbo type DIE.

[LTO] Bootstrapped on x86_64-unknown-linux-gnu.

OK for trunk?

Thanks,
Richard.

	PR debug/110295
	* dwarf2out.cc (process_scope_var): Continue processing
	the decl after setting a parent in case the existing DIE
	was in limbo.

	* g++.dg/debug/pr110295.C: New testcase.
---
 gcc/dwarf2out.cc                      |  3 ++-
 gcc/testsuite/g++.dg/debug/pr110295.C | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/pr110295.C

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index d89ffa66847..e70c47cec8d 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -26533,7 +26533,8 @@ process_scope_var (tree stmt, tree decl, tree origin, dw_die_ref context_die)
 
   if (die != NULL && die->die_parent == NULL)
     add_child_die (context_die, die);
-  else if (TREE_CODE (decl_or_origin) == IMPORTED_DECL)
+
+  if (TREE_CODE (decl_or_origin) == IMPORTED_DECL)
     {
       if (early_dwarf)
 	dwarf2out_imported_module_or_decl_1 (decl_or_origin, DECL_NAME (decl_or_origin),
diff --git a/gcc/testsuite/g++.dg/debug/pr110295.C b/gcc/testsuite/g++.dg/debug/pr110295.C
new file mode 100644
index 00000000000..10cad557095
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr110295.C
@@ -0,0 +1,19 @@
+// { dg-do compile }
+// { dg-options "-g" }
+
+template <typename T>
+struct QCachedT
+{
+  void operator delete(void *, T *) {}
+};
+template<int a>
+void exercise()
+{
+  struct thing_t
+    : QCachedT<thing_t>
+  {
+  };
+  thing_t *list[1];
+  new thing_t; // { dg-warning "" }
+}
+int main() { exercise<1>(); }
-- 
2.35.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-20  7:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <10678.123061906202700891@us-mta-531.us.mimecast.lan>
2023-06-19 17:18 ` [PATCH] debug/110295 - mixed up early/late debug for member DIEs Jason Merrill
2023-06-20  7:01   ` Richard Biener
2023-06-19 10:15 Richard Biener

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).