public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: jason@redhat.com
Subject: Re: [PATCH] Fix PR86654
Date: Wed, 25 Jul 2018 12:08:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.20.1807251405370.16707@zhemvz.fhfr.qr> (raw)
In-Reply-To: <alpine.LSU.2.20.1807241702000.16707@zhemvz.fhfr.qr>

On Tue, 24 Jul 2018, Richard Biener wrote:

> 
> I am testing the following patch to avoid forcing DIEs for a type context
> for method clones late via limbo processing.  Instead hang them off
> comp_unit_die if there is no early DIE for the function.
> 
> One question is whether the comment "If we're a nested function"
> matches up with the decl_function_context (decl) check or whether
> we really wanted to check DECL_CONTEXT (decl) == FUNCTION_DECL
> which would have made this particular case not match (DECL_CONTEXT
> is a RECORD_TYPE which context is a FUNCTION_DECL).
> 
> Another option is of course to make clones not inherit
> DECL_CONTEXT from the cloned function (for an artificial
> instance the "context" is somewhat arbitrary since it isn't
> going to be found by lookup).  In fact I long wanted to
> represent clones as artificial containers for an
> inline instance of the cloned function...
> 
> LTO bootstrap and regtest running on x86_64-unknown-linux-gnu.
> 
> If that succeeds I'm going to apply it as a stop-gap measure to
> make Firefox build again with LTO but I'm open to revising it.

So there was fallout, namely

FAIL: g++.dg/debug/dwarf2/lambda1.C  -std=gnu++11  scan-assembler-times 
DW_TAG_variable[^.]*.ascii "this.0" 2
FAIL: g++.dg/debug/dwarf2/lambda1.C  -std=gnu++14  scan-assembler-times 
DW_TAG_variable[^.]*.ascii "this.0" 2

see the PR for analysis.  The following revised patch mitigates this
by relying not on !context_die but on an explicit local_scope_p
for fulfilling the last part of the overall comment of this section:

         to have the same parent.  For local class methods, this doesn't
         apply; we just use the old DIE.  */

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, bootstrapped
and tested on x86_64-unknown-linux-gnu.

I have applied the patch for now, as said, I'm happy to revise later.

Richard.

2018-07-24  Richard Biener  <rguenther@suse.de>

	PR debug/86654
	* dwarf2out.c (dwarf2out_decl): Do not handle nested functions
	special wrt context_die late.
	(gen_subprogram_die): Re-use DIEs in local scope.

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 262940)
+++ gcc/dwarf2out.c	(working copy)
@@ -22766,6 +22766,7 @@ gen_subprogram_die (tree decl, dw_die_re
 	     */
 	    || (old_die->die_parent
 		&& old_die->die_parent->die_tag == DW_TAG_module)
+	    || local_scope_p (old_die->die_parent)
 	    || context_die == NULL)
 	   && (DECL_ARTIFICIAL (decl)
 	       || (get_AT_file (old_die, DW_AT_decl_file) == file_index
@@ -26702,8 +26703,11 @@ dwarf2out_decl (tree decl)
     case FUNCTION_DECL:
       /* If we're a nested function, initially use a parent of NULL; if we're
 	 a plain function, this will be fixed up in decls_for_scope.  If
-	 we're a method, it will be ignored, since we already have a DIE.  */
-      if (decl_function_context (decl)
+	 we're a method, it will be ignored, since we already have a DIE.
+	 Avoid doing this late though since clones of class methods may
+	 otherwise end up in limbo and create type DIEs late.  */
+      if (early_dwarf
+	  && decl_function_context (decl)
 	  /* But if we're in terse mode, we don't care about scope.  */
 	  && debug_info_level > DINFO_LEVEL_TERSE)
 	context_die = NULL;

      reply	other threads:[~2018-07-25 12:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-24 15:08 Richard Biener
2018-07-25 12:08 ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.20.1807251405370.16707@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).