Patchwork [pph] Handle hidden state in cp/decl2.c (issue5577059)

login
register
mail settings
Submitter Lawrence Crowl
Date Jan. 27, 2012, 1:52 a.m.
Message ID <20120127015212.82ABA22265D@jade.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/138103/
State New
Headers show

Comments

Lawrence Crowl - Jan. 27, 2012, 1:52 a.m.
Emit some state hidden in cp/decl2.c: pending_statics, deferred_fns, and
no_linkage_decls.

One tests is now passing, two tests are now okay, and three tests have
improved, but are still failing.



--
This patch is available for review at http://codereview.appspot.com/5577059

Patch

Index: gcc/testsuite/ChangeLog.pph

2012-01-26   Lawrence Crowl  <crowl@google.com>

	* g++.dg/pph/x1tmplclass1.cc: Mark passing.
	* g++.dg/pph/x1tmplclass2.cc: Mark okay.
	* g++.dg/pph/x4tmplclass1.cc: Mark okay.
	* g++.dg/pph/x4tmplclass2.cc: Change failure.
	* g++.dg/pph/z4tmplclass1.cc: Change failure.
	* g++.dg/pph/z4tmplclass2.cc: Change failure.

Index: gcc/cp/ChangeLog.pph

2012-01-26   Lawrence Crowl  <crowl@google.com>

	* decl2.c (#include "pph.h"): New.
	(pph_out_decl2_hidden_state): New.
	(pph_in_decl2_hidden_state): New.
	(pph_dump_decl2_hidden_state): New.
	* Make-lang.in (cp/decl.o): Add dependence on $(CXX_PPH_H)
	* pph.h (pph_dump_vec_tree): Externalize.
	(pph_out_tree_vec): Externalize.
	(pph_in_tree_vec): Externalize.
	(pph_union_into_tree_vec): Externalize.
	(pph_out_decl2_hidden_state): New.
	(pph_in_decl2_hidden_state): New.
	(pph_dump_decl2_hidden_state): New.
	* pph-core.c (pph_dump_vec_tree): Externalize.
	(pph_dump_global_state): Call pph_dump_decl2_hidden_state.
	* pph-out.c (pph_out_tree_vec): Externalize.
	(pph_write_file): Call pph_out_decl2_hidden_state.
	* pph-in.c (pph_in_tree_vec): Externalize.
	(pph_union_into_tree_vec): Externalize.
	(pph_read_file_1): Call pph_in_decl2_hidden_state.


Index: gcc/testsuite/g++.dg/pph/x1tmplclass1.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x1tmplclass1.cc	(revision 183576)
+++ gcc/testsuite/g++.dg/pph/x1tmplclass1.cc	(working copy)
@@ -1,7 +1,2 @@ 
-// pph asm xdiff 11432
-// xfail BOGUS MISSVAR
-// The assembly is missing a template class static member variable
-// base<char>::variable instantiated in a prior pph file.
-
 #include "x0tmplclass13.h"
 #include "a0tmplclass1_u.h"
Index: gcc/testsuite/g++.dg/pph/x1tmplclass2.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x1tmplclass2.cc	(revision 183576)
+++ gcc/testsuite/g++.dg/pph/x1tmplclass2.cc	(working copy)
@@ -1,7 +1,5 @@ 
-// pph asm xdiff 37711
-// xfail BOGUS MISSVAR
-// The assembly is missing a template class static member variable
-// base<char>::variable instantiated in a prior pph file.
-// Others symbols are emitted in a different order.
+// pph asm xokay 60608
+// Symbols are emitted in a different order.
+
 #include "x0tmplclass23.h"
 #include "a0tmplclass2_u.h"
Index: gcc/testsuite/g++.dg/pph/z4tmplclass1.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/z4tmplclass1.cc	(revision 183576)
+++ gcc/testsuite/g++.dg/pph/z4tmplclass1.cc	(working copy)
@@ -1,5 +1,5 @@ 
-// pph asm xdiff 65352
-// xfail BOGUS DUPVAR DUPFUNC
+// pph asm xdiff 43522
+// xfail DUPVAR DUPFUNC
 
 #include "x0tmplclass13.h"
 #include "x0tmplclass14.h"
Index: gcc/testsuite/g++.dg/pph/z4tmplclass2.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/z4tmplclass2.cc	(revision 183576)
+++ gcc/testsuite/g++.dg/pph/z4tmplclass2.cc	(working copy)
@@ -1,5 +1,5 @@ 
-// pph asm xdiff 46430
-// xfail BOGUS DUPVAR DUPFUNC
+// pph asm xdiff 26423
+// xfail DUPVAR DUPFUNC
 
 #include "x0tmplclass23.h"
 #include "x0tmplclass24.h"
Index: gcc/testsuite/g++.dg/pph/x4tmplclass1.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4tmplclass1.cc	(revision 183576)
+++ gcc/testsuite/g++.dg/pph/x4tmplclass1.cc	(working copy)
@@ -1,6 +1,6 @@ 
-// pph asm xokay 63957
-// Assembly differences seem to be due to the order in which the
-// symbols in the template hash tables are emitted.
+// pph asm xokay 03516
+// Label numbers are different.
+
 #include "x0tmplclass11.h"
 #include "x0tmplclass12.h"
 #include "a0tmplclass1_u.h"
Index: gcc/testsuite/g++.dg/pph/x4tmplclass2.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4tmplclass2.cc	(revision 183576)
+++ gcc/testsuite/g++.dg/pph/x4tmplclass2.cc	(working copy)
@@ -1,5 +1,6 @@ 
-// pph asm xdiff 54639
-// generating different sets of variables
+// pph asm xdiff 51443
+// xfail DUPFUNC
+
 #include "x0tmplclass21.h"
 #include "x0tmplclass22.h"
 #include "a0tmplclass2_u.h"
Index: gcc/cp/pph-core.c
===================================================================
--- gcc/cp/pph-core.c	(revision 183576)
+++ gcc/cp/pph-core.c	(working copy)
@@ -273,7 +273,7 @@  pph_dump_binding (FILE *file, cp_binding
 
 /* Dump a tree vec v for PPH.  */
 
-static void
+void
 pph_dump_vec_tree (FILE *file, VEC(tree,gc) *v)
 {
   unsigned i;
@@ -301,6 +301,7 @@  pph_dump_global_state (FILE *file, const
   fprintf (file, "\nPPH: unemitted_tinfo_decls\n");
   pph_dump_vec_tree (file, unemitted_tinfo_decls);
   fprintf (file, "\nPPH: END GLOBAL STATE\n\n");
+  pph_dump_decl2_hidden_state (file);
 }
 
 
Index: gcc/cp/Make-lang.in
===================================================================
--- gcc/cp/Make-lang.in	(revision 183576)
+++ gcc/cp/Make-lang.in	(working copy)
@@ -276,7 +276,7 @@  cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H)
 cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) debug.h langhooks.h \
   $(LANGHOOKS_DEF_H) $(C_COMMON_H) gtype-cp.h gt-cp-cp-lang.h \
   cp/cp-objcp-common.h $(EXPR_H) $(TARGET_H) $(CXX_PARSER_H)
-cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) cp/decl.h \
+cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) cp/decl.h $(CXX_PPH_H) \
   output.h toplev.h $(HASHTAB_H) $(RTL_H) \
   cp/operators.def $(TM_P_H) $(TREE_INLINE_H) $(DIAGNOSTIC_H) $(C_PRAGMA_H) \
   debug.h gt-cp-decl.h $(TIMEVAR_H) $(TARGET_H) $(PLUGIN_H) \
Index: gcc/cp/pph.h
===================================================================
--- gcc/cp/pph.h	(revision 183576)
+++ gcc/cp/pph.h	(working copy)
@@ -144,6 +144,7 @@  extern void pph_loaded (void);
 extern void pph_finish (void);
 extern void pph_dump_location (FILE *file, location_t loc);
 extern void pph_dump_tree_name (FILE *file, tree t, int flags);
+extern void pph_dump_vec_tree (FILE *file, VEC(tree,gc) *v);
 extern void pph_init_include_tree (void);
 extern void pph_dump_includes (FILE *, pph_stream *, unsigned);
 
@@ -151,6 +152,7 @@  extern void pph_dump_includes (FILE *, p
 extern void pph_out_uint (pph_stream *stream, unsigned int value);
 extern void pph_out_location (pph_stream *stream, location_t loc);
 extern void pph_out_tree (pph_stream *stream, tree t);
+extern void pph_out_tree_vec (pph_stream *stream, VEC(tree,gc) *v);
 extern void pph_out_record_marker (pph_stream *stream,
 			enum pph_record_marker marker, enum pph_tag tag);
 void pph_add_decl_to_symtab (tree, enum pph_symtab_action, bool, bool);
@@ -159,10 +161,17 @@  void pph_add_decl_to_symtab (tree, enum 
 extern unsigned int pph_in_uint (pph_stream *stream);
 extern location_t pph_in_location (pph_stream *stream);
 extern tree pph_in_tree (pph_stream *stream);
+extern VEC(tree,gc) *pph_in_tree_vec (pph_stream *stream);
+extern void pph_union_into_tree_vec (VEC(tree,gc) **into, VEC(tree,gc) *from);
 extern enum pph_record_marker pph_in_record_marker (pph_stream *stream,
 			enum pph_tag *tag_p);
 extern bool pph_files_read (void);
 
+/* In decl2.c.  */
+extern void pph_out_decl2_hidden_state (pph_stream *stream);
+extern void pph_in_decl2_hidden_state (pph_stream *stream);
+extern void pph_dump_decl2_hidden_state (FILE *file);
+
 /* In name-lookup.c.  */
 struct binding_table_s;
 extern void pph_out_binding_table (pph_stream *, struct binding_table_s *);
Index: gcc/cp/pph-out.c
===================================================================
--- gcc/cp/pph-out.c	(revision 183576)
+++ gcc/cp/pph-out.c	(working copy)
@@ -983,7 +983,7 @@  vec2vec_filter (pph_stream *stream, VEC(
 
 /* Write all the trees in VEC V to STREAM.  */
 
-static void
+void
 pph_out_tree_vec (pph_stream *stream, VEC(tree,gc) *v)
 {
   unsigned i;
@@ -2707,6 +2707,8 @@  pph_write_file (pph_stream *stream)
 
   pph_out_tree (stream, static_aggregates);
 
+  pph_out_decl2_hidden_state (stream);
+
   /* Emit the symbol table.  */
   pph_out_symtab (stream);
 
Index: gcc/cp/decl2.c
===================================================================
--- gcc/cp/decl2.c	(revision 183576)
+++ gcc/cp/decl2.c	(working copy)
@@ -54,6 +54,7 @@  along with GCC; see the file COPYING3.  
 #include "splay-tree.h"
 #include "langhooks.h"
 #include "c-family/c-ada-spec.h"
+#include "pph.h"
 
 extern cpp_reader *parse_in;
 
@@ -4397,4 +4398,41 @@  mark_used (tree decl)
   return true;
 }
 
+
+/* Write out hidden global state to PPH STREAM.  */
+
+void
+pph_out_decl2_hidden_state (pph_stream *stream)
+{
+  pph_out_tree_vec (stream, pending_statics);
+  pph_out_tree_vec (stream, deferred_fns);
+  pph_out_tree_vec (stream, no_linkage_decls);
+}
+
+
+/* Read in hidden global state from PPH STREAM.  */
+
+void
+pph_in_decl2_hidden_state (pph_stream *stream)
+{
+  pph_union_into_tree_vec (&pending_statics, pph_in_tree_vec (stream));
+  pph_union_into_tree_vec (&deferred_fns, pph_in_tree_vec (stream));
+  pph_union_into_tree_vec (&no_linkage_decls, pph_in_tree_vec (stream));
+}
+
+
+/* Dump hidden global state.  */
+
+void
+pph_dump_decl2_hidden_state (FILE *file)
+{
+  fprintf (file, "\nPPH: pending_statics\n");
+  pph_dump_vec_tree (file, pending_statics);
+  fprintf (file, "\nPPH: deferred_fns\n");
+  pph_dump_vec_tree (file, deferred_fns);
+  fprintf (file, "\nPPH: no_linkage_decls\n");
+  pph_dump_vec_tree (file, no_linkage_decls);
+}
+
+
 #include "gt-cp-decl2.h"
Index: gcc/cp/pph-in.c
===================================================================
--- gcc/cp/pph-in.c	(revision 183576)
+++ gcc/cp/pph-in.c	(working copy)
@@ -683,7 +683,7 @@  pph_in_token_cache (pph_stream *stream)
 
 /* Read and return a gc VEC of trees from STREAM.  */
 
-static VEC(tree,gc) *
+VEC(tree,gc) *
 pph_in_tree_vec (pph_stream *stream)
 {
   HOST_WIDE_INT i, num;
@@ -782,7 +782,7 @@  pph_union_two_tree_vecs (VEC(tree,gc) *l
 /* Union FROM one tree vec with and INTO a tree vec.  The INTO argument will
    have an updated value.  The FROM argument is no longer valid.  */
 
-static void
+void
 pph_union_into_tree_vec (VEC(tree,gc) **into, VEC(tree,gc) *from)
 {
   if (!VEC_empty (tree, from))
@@ -3080,6 +3080,8 @@  pph_read_file_1 (pph_stream *stream)
   file_static_aggregates = pph_in_tree (stream);
   static_aggregates = chainon (file_static_aggregates, static_aggregates);
 
+  pph_in_decl2_hidden_state (stream);
+
   /* Read and process the symbol table.  */
   pph_in_symtab (stream);