public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: jason merrill <jason@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [debug-early] Handle specification of class scoped static functions
Date: Fri, 20 Mar 2015 17:56:00 -0000	[thread overview]
Message-ID: <550C5F3A.1030802@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 895 bytes --]

Hi Jason.

For class scoped static functions:

		   class C {
		   public:
		     static void moo () {}
		   };

...we are calling gen_subprogram on moo() the usual handful of times 
(during early dwarf): once as a member of C and once because moo() is a 
reachable function.  However, on the second time, we reuse the cached 
DIE and merely remove the DW_AT_declaration attribute:

	  /* Clear out the declaration attribute, but leave the
	     parameters so they can be augmented with location
	     information later.  */
	  remove_AT (subr_die, DW_AT_declaration);

This causes us to reuse the DIE from within the class, instead of adding 
a specification of this cached DIE.

With the attached tweak we fix this problem, and about a hundred gdb 
regressions.  This IMHO is a "Good Thing" :).

Would you be so kind as to look at this two-liner to make sure you're OK 
with it?

Thanks.
Aldy

[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 1179 bytes --]

commit cec08d43caffbf086720ac3994d068010dc103c9
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Fri Mar 20 09:55:31 2015 -0700

    Handle specification of class scoped static functions.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 8884afd..1325dfe 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -18770,7 +18770,20 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
       struct dwarf_file_data * file_index = lookup_filename (s.file);
       if (((is_cu_die (old_die->die_parent)
 	    || context_die == NULL
-	    || dumped_early)
+	    || (dumped_early
+		/* For class scoped static functions, the dumped early
+		   version was the declaration, whereas the next time
+		   around with a different context should be the
+		   specification.  In this case, avoid reusing the
+		   DIE, but generate a specification below. E.g.:
+
+		   class C {
+		   public:
+		     static void moo () {}
+		   };
+		*/
+		&& (!is_cu_die (context_die)
+		    || !class_or_namespace_scope_p (old_die->die_parent))))
 	   && (DECL_ARTIFICIAL (decl)
 	       || (get_AT_file (old_die, DW_AT_decl_file) == file_index
 		   && (get_AT_unsigned (old_die, DW_AT_decl_line)

             reply	other threads:[~2015-03-20 17:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 17:56 Aldy Hernandez [this message]
2015-03-20 21:21 ` Jason Merrill
2015-03-21  0:11   ` Aldy Hernandez
2015-04-03 14:48     ` Jason Merrill
2015-04-13 18:01       ` Aldy Hernandez
2015-04-13 21:05         ` Jason Merrill
2015-04-13 21:08           ` Jason Merrill

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=550C5F3A.1030802@redhat.com \
    --to=aldyh@redhat.com \
    --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).