File gcc41-pr26881.patch of Package gcc

2006-05-11  Jan Hubicka  <jh@suse.cz>

	PR debug/26881
	* Makefile.in (gt-cgraphunit.h): Add.
	* cgraphunit.c: Include gt-cgraphunit.h.
	(local_static_output): New static vector.
	(cgraph_varpool_assemble_decl): Defer outputting debug info
	for local statics to...
	(cgraph_varpool_debug_local_statics): ... here.
	(cgraph_optimize): Use it.

2006-05-12  Jakub Jelinek  <jakub@redhat.com>

	PR debug/26881
	* gcc.dg/debug/pr26881.c: New test.

--- gcc/cgraphunit.c.jj	2005-10-28 23:33:15.000000000 +0200
+++ gcc/cgraphunit.c	2006-05-12 19:37:58.000000000 +0200
@@ -173,6 +173,10 @@ static void cgraph_expand_function (stru
 static tree record_reference (tree *, int *, void *);
 static void cgraph_analyze_function (struct cgraph_node *node);
 
+/* Local static variables needs to be passed to debug info after the function
+   bodies are compiled.  */
+static GTY(()) VEC(tree,gc) *local_static_output;
+
 /* Records tree nodes seen in record_reference.  Simply using
    walk_tree_without_duplicates doesn't guarantee each node is visited
    once because it gets a new htab upon each recursive call from
@@ -807,6 +811,15 @@ verify_cgraph (void)
 }
 
 
+static void
+cgraph_varpool_debug_local_statics (void)
+{
+  timevar_push (TV_SYMOUT);
+  while (VEC_length (tree, local_static_output) > 0)
+    (*debug_hooks->global_decl) (VEC_pop (tree, local_static_output));
+  timevar_pop (TV_SYMOUT);
+}
+
 /* Output all variables enqueued to be assembled.  */
 bool
 cgraph_varpool_assemble_pending_decls (void)
@@ -837,9 +850,9 @@ cgraph_varpool_assemble_pending_decls (v
 	          || TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
 	      && errorcount == 0 && sorrycount == 0)
 	    {
-	      timevar_push (TV_SYMOUT);
-	      (*debug_hooks->global_decl) (decl);
-	      timevar_pop (TV_SYMOUT);
+	      if (!local_static_output)
+		local_static_output = VEC_alloc (tree, gc, 20);
+	      VEC_safe_push (tree, gc, local_static_output, decl);
 	    }
 	  changed = true;
 	}
@@ -1235,6 +1248,7 @@ cgraph_optimize (void)
   if (!flag_unit_at_a_time)
     {
       cgraph_varpool_assemble_pending_decls ();
+      cgraph_varpool_debug_local_statics ();
       return;
     }
 
@@ -1308,6 +1322,7 @@ cgraph_optimize (void)
 	internal_error ("nodes with no released memory found");
     }
 #endif
+ cgraph_varpool_debug_local_statics ();
 }
 
 /* Generate and emit a static constructor or destructor.  WHICH must be
@@ -1521,3 +1536,5 @@ cgraph_function_versioning (struct cgrap
   new_version_node->lowered = true;
   return new_version_node;
 }
+
+#include "gt-cgraphunit.h"
--- gcc/Makefile.in.jj	2006-04-10 15:03:43.000000000 +0200
+++ gcc/Makefile.in	2006-05-12 19:36:03.000000000 +0200
@@ -2179,7 +2179,8 @@ cgraphunit.o : cgraphunit.c $(CONFIG_H) 
    $(TREE_H) langhooks.h $(TREE_INLINE_H) toplev.h $(FLAGS_H) $(GGC_H) \
    $(TARGET_H) $(CGRAPH_H) intl.h pointer-set.h function.h $(TREE_GIMPLE_H) \
    $(TREE_FLOW_H) tree-pass.h $(C_COMMON_H) debug.h $(DIAGNOSTIC_H) \
-   $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) ipa-prop.h
+   $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) ipa-prop.h \
+   gt-cgraphunit.h
 ipa.o : ipa.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(CGRAPH_H) 
 ipa-prop.o : ipa-prop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h  \
    langhooks.h $(GGC_H) target.h $(CGRAPH_H) ipa-prop.h \
@@ -2748,7 +2749,7 @@ GTFILES = $(srcdir)/input.h $(srcdir)/co
   $(srcdir)/cselib.h $(srcdir)/basic-block.h  $(srcdir)/cgraph.h \
   $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \
   $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
-  $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c\
+  $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/cgraphunit.c \
   $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
   $(srcdir)/dojump.c $(srcdir)/tree-profile.c \
   $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
@@ -2791,7 +2792,7 @@ gt-tree-profile.h gt-tree-ssa-address.h 
 gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
 gt-tree-phinodes.h gt-tree-nested.h \
 gt-tree-ssa-operands.h gt-tree-ssa-propagate.h \
-gt-tree-ssa-structalias.h \
+gt-tree-ssa-structalias.h gt-cgraphunit.h \
 gt-stringpool.h gt-targhooks.h gt-omp-low.h : s-gtype ; @true
 
 define echo_quoted_to_gtyp
--- gcc/testsuite/gcc.dg/debug/pr26881.c.jj	2006-05-12 19:40:54.000000000 +0200
+++ gcc/testsuite/gcc.dg/debug/pr26881.c	2006-05-12 19:43:51.000000000 +0200
@@ -0,0 +1,15 @@
+/* PR debug/26881 */
+/* { dg-do compile } */
+
+int
+foo ()
+{
+  if (0)
+    {
+      static union { } u;
+      typedef char tt;
+      static tt cccc[8];
+      return cccc[0] == 0x01 && cccc[1] == 0x02;
+    }
+  return 0;
+}
openSUSE Build Service is sponsored by