This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR c++/27574


Ian Lance Taylor a écrit :

[...]

Forwarding Honza's reply back to the list.

[...]



Hi, the patch should cause ICE on enable checking compiler in the loop verifying that all function bodies are removed. Naturally I would a lot preffer this invriant to remain (that is that we don't have live bodies at the end of compilation). I guess plan of generating info earlier that would probably make most sense to me is not that good for stage3, so I guess the patch is fine (if the verification loop is updated to skip abstract functions too).

So in that spirit, would the attached patch be any better ? assuming it passes distcheck, of course.


After all we don't have that many abstract functions produced...

Do we really need all the body for debug output?  I think tree-SSA pass
is killing most of it anyway, so if we need something like just
DECL_INITIAL, then we can perhaps teach cgraph code to keep only that
around.


Yes, I have the impression that just having DECL_INITIAL should be enough. I am not sure we need DECL_SAVED_TREE() to generate the debug info, but I am not sure.


Cheers,

Dodji.

commit 233d1f0161c434818099964ea09c231bb9c283b0
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Fri Sep 5 12:23:33 2008 +0200

    Fix for PR c++/27574
    
    	PR c++/27574
    	* gcc/cgraph.c (cgraph_remove_node): Do not remove the body of
    	  abstract functions. It might be useful to emit debugging
    	  information. This is a patch from Ian Lance Taylor.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 92d7768..a959e56 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-26  Dodji Seketeli  <dodji@redhat.com>
+
+	PR c++/27574
+	* cgraph.c (cgraph_remove_node): Do not remove the body of
+	  abstract functions. It might be useful to emit debugging
+	  information. This is a patch from Ian Lance Taylor.
+	* cgraphunit.c (cgraph_optimize): Do not cry when bodies of abstract
+	  functions are still around. They are useful to output debug info.
+
 2008-06-05  Richard Sandiford  <rdsandiford@googlemail.com>
 
 	* config/mips/mips.c (mips_emit_loadgp): Emit a blockage if
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 199c639..3d21190 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -479,6 +479,14 @@ cgraph_remove_node (struct cgraph_node *node)
 	kill_body = true;
     }
 
+  /* We don't release the body of abstract functions, because they may
+     be needed when emitting debugging information.  In particular
+     this will happen for C++ constructors/destructors.  FIXME:
+     Ideally we would check to see whether there are any reachable
+     functions whose DECL_ABSTRACT_ORIGIN points to this decl.  */
+  if (DECL_ABSTRACT (node->decl))
+    kill_body = false;
+
   if (kill_body && !dump_enabled_p (TDI_tree_all) && flag_unit_at_a_time)
     {
       DECL_SAVED_TREE (node->decl) = NULL;
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 65a8651..1fbc80d 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1391,7 +1391,10 @@ cgraph_optimize (void)
       for (node = cgraph_nodes; node; node = node->next)
 	if (node->analyzed
 	    && (node->global.inlined_to
-	        || DECL_SAVED_TREE (node->decl)))
+	        || DECL_SAVED_TREE (node->decl))
+            /* Abstract functions are needed to output debug info,
+               so don't comply about them if they are still around.  */
+            && !DECL_ABSTRACT (node->decl))
 	  {
 	    error_found = true;
 	    dump_cgraph_node (stderr, node);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 47a7b2c..2154135 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-04  Dodji Seketeli  <dodji@gnome.org>
+
+	PR c++/27574
+	* g++.dg/debug/dwarf2/local-var-in-contructor.C: New testcase.
+
 2008-05-29  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* gcc.dg/nested-func-6.c: New test.
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C b/gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C
new file mode 100644
index 0000000..d61d27f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C
@@ -0,0 +1,30 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR27574
+// { dg-do compile }
+// { dg-options "-O0 -g" }
+// { dg-final { scan-assembler "problem" } }
+
+void f (int *)
+{
+}
+
+class A
+{
+public:
+ A(int i);
+};
+
+A::A(int i)
+{
+ int *problem = new int(i);
+ f (problem);
+}
+
+int
+main (void)
+{
+  A a (0);
+
+  return 0;
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]