Patchwork [pph] Merge unemitted_tinfo_decls and keyed_classes (issue5575053)

login
register
mail settings
Submitter Lawrence Crowl
Date Jan. 24, 2012, 11:31 p.m.
Message ID <20120124233104.449EC2225C8@jade.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/137688/
State New
Headers show

Comments

Lawrence Crowl - Jan. 24, 2012, 11:31 p.m.
Merge unemitted_tinfo_decls and keyed_classes.  We do not have a test
case failing for keyed_classes, so the latter is anticipatory.

Add a 'pph asm xokay' test marker for assembly differences that are
benign.  We would rather have identical assembly, but it is just not
important right now.  These will be treated as passes.

Clarify a few other failures.

Make various debug/trace dump changes.



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

Patch

Index: gcc/testsuite/ChangeLog.pph

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

	* lib/dg-pph.exp: Add an asm 'xokay' for benign assembly differences.
	* g++.dg/pph/x4keyno.cc: Bug fixed, now xokay.
	* g++.dg/pph/x4keyed.cc: Bug fixed, now xokay.
	* g++.dg/pph/x4keyex.cc: Mark xokay.
	* g++.dg/pph/x4tmplclass1.cc: Mark xokay.
	* g++.dg/pph/x1tmplclass2.cc: Clarify failure.
	* g++.dg/pph/x4tmplclass2.cc: Clarify failure.

Index: gcc/cp/ChangeLog.pph

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

	* pph-streamer.h (pph_dump_global_state): New.
	(pph_dump_namespace): Removed; callers now use pph_dump_global_state.
	* pph-core.c (pph_dump_tree_name): Add tree pointer.
	(pph_dump_vec_tree): New.
	(pph_dump_namespace): Remove message parameter.
	(pph_dump_global_state): New.
	(pph_loaded): Call pph_dump_global_state instead of pph_dump_namespace.
	* pph-out.c (pph_write_file): Call pph_dump_global_state instead of
	pph_dump_namespace.
	* error.c (dump_decl): Protect against null pointers.
	* name-lookup.c (pph_debug_binding_action): Add PPH: output label.
	(pph_debug_binding_inaction): Add PPH: output label.
	(pph_set_identifier_bindings): Modify debug label.
	(pph_debug_overload_binding_action): New.
	(pph_set_namespace_bindings): Call pph_debug_overload_binding_action
	instead of pph_debug_binding_action.
	(pph_add_overload): Remove unused.
	* pph-in.c (pph_is_on_chain): New.
	(pph_union_into_chain): New.
	(pph_read_file_1): Call pph_union_into_chain for keyed_classes.
	Call pph_union_into_tree_vec for unemitted_tinfo_decls.
	Call pph_dump_global_state instead of pph_dump_namespace.


Index: gcc/testsuite/lib/dg-pph.exp
===================================================================
--- gcc/testsuite/lib/dg-pph.exp	(revision 183499)
+++ gcc/testsuite/lib/dg-pph.exp	(working copy)
@@ -166,9 +166,14 @@  proc dg-pph-pos { subdir test options ma
 
     # The sources mark when they expect the comparison to differ.
     # When marked with xdiff, the difference is a problem.
+    # When marked with xokay, the difference is not causing a problem.
     # When marked with xwant, the difference is what we want.
     set xdiff_entry [grep $test "pph asm xdiff( )*\[0-9\]*"]
+    set xokay_entry [grep $test "pph asm xokay( )*\[0-9\]*"]
     set xwant_entry [grep $test "pph asm xwant( )*\[0-9\]*"]
+    if { $xokay_entry != ""} {
+	set xwant_entry $xokay_entry
+    }
     set xdiff [llength $xdiff_entry]
     set xwant [llength $xwant_entry]
     if { $adiff == 0 } {
Index: gcc/testsuite/g++.dg/pph/x4keyno.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4keyno.cc	(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4keyno.cc	(working copy)
@@ -1,5 +1,4 @@ 
-// { dg-xfail-if "redefinition problems" { *-*-* } { "-fpph-map=pph.map" } }
-// { dg-excess-errors "The variable for the typeinfo name for 'keyno' is duplicated." }
+// pph asm xokay 32642
 
 #include "x0keyno1.h"
 #include "x0keyno2.h"
Index: gcc/testsuite/g++.dg/pph/x1tmplclass2.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x1tmplclass2.cc	(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x1tmplclass2.cc	(working copy)
@@ -1,4 +1,7 @@ 
 // pph asm xdiff 37711
-// Soft failure.  Symbols are emitted in different order in pph compile.
+// 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.
 #include "x0tmplclass23.h"
 #include "a0tmplclass2_u.h"
Index: gcc/testsuite/g++.dg/pph/x4keyex.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4keyex.cc	(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4keyex.cc	(working copy)
@@ -1,4 +1,4 @@ 
-// pph asm xdiff 32642
+// pph asm xokay 32642
 //
 // This test case fails to compare because LFB/LFE labels are different.
 //
Index: gcc/testsuite/g++.dg/pph/x4tmplclass1.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4tmplclass1.cc	(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4tmplclass1.cc	(working copy)
@@ -1,4 +1,4 @@ 
-// pph asm xdiff 63957
+// pph asm xokay 63957
 // Assembly differences seem to be due to the order in which the
 // symbols in the template hash tables are emitted.
 #include "x0tmplclass11.h"
Index: gcc/testsuite/g++.dg/pph/x4keyed.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4keyed.cc	(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4keyed.cc	(working copy)
@@ -1,5 +1,4 @@ 
-// { dg-xfail-if "redefinition problems" { *-*-* } { "-fpph-map=pph.map" } }
-// { dg-excess-errors "typeinfo redefinition problems.  May be merging issue for global binding" }
+// pph asm xokay 27667
 
 #include "x0keyed1.h"
 #include "x0keyed2.h"
Index: gcc/testsuite/g++.dg/pph/x4tmplclass2.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4tmplclass2.cc	(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4tmplclass2.cc	(working copy)
@@ -1,4 +1,5 @@ 
 // pph asm xdiff 54639
+// generating different sets of variables
 #include "x0tmplclass21.h"
 #include "x0tmplclass22.h"
 #include "a0tmplclass2_u.h"
Index: gcc/cp/pph-core.c
===================================================================
--- gcc/cp/pph-core.c	(revision 183499)
+++ gcc/cp/pph-core.c	(working copy)
@@ -125,6 +125,7 @@  pph_dump_tree_name (FILE *file, tree t, 
 {
   enum tree_code code = TREE_CODE (t);
   const char *text = pph_tree_code_text (code);
+  fprintf (file, "%p ", (void *)t);
   if (DECL_P (t))
     fprintf (file, "%s %s\n", text, decl_as_string (t, flags));
   else if (TYPE_P (t))
@@ -146,11 +147,9 @@  pph_dump_binding (FILE *file, cp_binding
 
 /* Dump namespace NS for PPH.  */
 
-void
-pph_dump_namespace (FILE *file, tree ns, const char *msg)
+static void
+pph_dump_namespace (FILE *file, tree ns)
 {
-  if (msg)
-    fprintf (file, "\nPPH: %s\n", msg);
   fprintf (file, "namespace ");
   pph_dump_tree_name (file, ns, 0);
   fprintf (file, "{\n");
@@ -185,11 +184,44 @@  pph_dump_binding (FILE *file, cp_binding
     {
       next = DECL_CHAIN (t);
       if (!DECL_IS_BUILTIN (t))
-        pph_dump_namespace (file, t, (const char *)NULL);
+        pph_dump_namespace (file, t);
     }
 }
 
 
+/* Dump a tree vec v for PPH.  */
+
+void
+pph_dump_vec_tree (FILE *file, VEC(tree,gc) *v)
+{
+  unsigned i;
+  tree t;
+  FOR_EACH_VEC_ELT (tree, v, i, t)
+    pph_dump_tree_name (file, t, 0);
+}
+
+
+
+/* Dump global symbol information for PPH.  */
+
+void
+pph_dump_global_state (FILE *file, const char *msg)
+{
+  fprintf (file, "\nPPH: BEGIN GLOBAL STATE ");
+  if (msg)
+    fprintf (file, "%s", msg);
+  fprintf (file, "\n");
+  pph_dump_namespace (file, global_namespace);
+  fprintf (file, "\nPPH: static_aggregates\n");
+  pph_dump_chain (file, static_aggregates);
+  fprintf (file, "\nPPH: keyed_classes\n");
+  pph_dump_chain (file, keyed_classes);
+  fprintf (file, "\nPPH: unemitted_tinfo_decls\n");
+  pph_dump_vec_tree (file, unemitted_tinfo_decls);
+  fprintf (file, "\nPPH: END GLOBAL STATE\n\n");
+}
+
+
 /* Trace a record MARKER and TAG.  */
 
 static const char *marker_strings[] =
@@ -868,7 +900,7 @@  pph_loaded (void)
 {
   pph_set_global_identifier_bindings();
   if (flag_pph_dump_tree)
-    pph_dump_namespace (pph_logfile, global_namespace, "after all pph read");
+    pph_dump_global_state (pph_logfile, "after all pph read");
 }
 
 
Index: gcc/cp/error.c
===================================================================
--- gcc/cp/error.c	(revision 183499)
+++ gcc/cp/error.c	(working copy)
@@ -1130,7 +1130,10 @@  dump_decl (tree t, int flags)
       break;
 
     case LABEL_DECL:
-      pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t));
+      if (DECL_NAME (t))
+        pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t));
+      else
+        pp_cxx_ws_string (cxx_pp, "<null>");
       break;
 
     case CONST_DECL:
Index: gcc/cp/pph-out.c
===================================================================
--- gcc/cp/pph-out.c	(revision 183499)
+++ gcc/cp/pph-out.c	(working copy)
@@ -2696,7 +2696,7 @@  pph_write_file (pph_stream *stream)
   pph_out_symtab (stream);
 
   if (flag_pph_dump_tree)
-    pph_dump_namespace (pph_logfile, global_namespace, "after pph write");
+    pph_dump_global_state (pph_logfile, "after pph write");
 }
 
 
Index: gcc/cp/pph-streamer.h
===================================================================
--- gcc/cp/pph-streamer.h	(revision 183499)
+++ gcc/cp/pph-streamer.h	(working copy)
@@ -249,7 +249,7 @@  enum pph_trace_end
 
 /* In pph-core.c.  */
 const char *pph_tree_code_text (enum tree_code code);
-void pph_dump_namespace (FILE *, tree ns, const char *msg);
+void pph_dump_global_state (FILE *, const char *msg);
 pph_stream *pph_stream_registry_lookup (const char *);
 void pph_stream_set_header_name (pph_stream *, const char *);
 pph_stream *pph_stream_open (const char *, const char *);
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 183499)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -6105,7 +6105,21 @@  pph_debug_binding_action (const char *ac
 {
   if (flag_pph_debug >= 5 || (flag_pph_debug >= 2 && !DECL_IS_BUILTIN (decl)))
     {
-      fprintf (pph_logfile, "%s ", action);
+      fprintf (pph_logfile, "PPH: %s ", action);
+      pph_dump_tree_name (pph_logfile, decl, 0);
+    }
+}
+
+
+/*  Dump a taken binding action for overloads.  */
+
+static void
+pph_debug_overload_binding_action (const char *action, tree ovld)
+{
+  tree decl = OVL_CURRENT (ovld);
+  if (flag_pph_debug >= 5 || (flag_pph_debug >= 2 && !DECL_IS_BUILTIN (decl)))
+    {
+      fprintf (pph_logfile, "PPH: %s ", action);
       pph_dump_tree_name (pph_logfile, decl, 0);
     }
 }
@@ -6117,7 +6131,7 @@  pph_debug_binding_inaction (const char *
 {
   if (flag_pph_debug >= 5 || (flag_pph_debug >= 3 && !DECL_IS_BUILTIN (decl)))
     {
-      fprintf (pph_logfile, "not %s ", action);
+      fprintf (pph_logfile, "PPH: not %s ", action);
       pph_dump_tree_name (pph_logfile, decl, 0);
     }
 }
@@ -6149,7 +6163,7 @@  pph_set_identifier_bindings (tree decl, 
   tree id = DECL_NAME (decl);
   if (id)
     {
-      pph_debug_binding_action ("i-bind", decl);
+      pph_debug_binding_action ("push bind", decl);
       push_binding (id, decl, bl);
     }
 }
@@ -6164,22 +6178,6 @@  pph_set_chain_identifier_bindings (tree 
 }
 
 
-#if 0
-/* Add an overload to a binding.  */
-
-static tree
-pph_add_overload (tree decl, tree older)
-{
-  tree newer;
-  if (older && TREE_CODE (older) != OVERLOAD)
-    newer = ovl_cons (decl, ovl_cons (older, NULL_TREE));
-  else
-    newer = ovl_cons (decl, older);
-  return newer;
-}
-#endif
-
-
 /*  Set a namespace identifier binding.  */
 
 static void
@@ -6220,7 +6218,7 @@  pph_set_namespace_bindings (tree decl, c
       if (TREE_CODE (decl) == OVERLOAD)
 	{
 	  b->value = decl;
-	  pph_debug_binding_action ("ovl bind", decl);
+	  pph_debug_overload_binding_action ("ovl bind", decl);
 	}
       else if (TREE_CODE (b->value) == TYPE_DECL &&
     	   TREE_CODE (decl) != TYPE_DECL)
Index: gcc/cp/pph-in.c
===================================================================
--- gcc/cp/pph-in.c	(revision 183499)
+++ gcc/cp/pph-in.c	(working copy)
@@ -810,6 +810,37 @@  pph_union_into_tree_vec (VEC(tree,gc) **
 
 /******************************************************************** chains */
 
+/* Test whether or not a tree T is on a CHAIN.  */
+
+static bool
+pph_is_on_chain (tree chain, tree t)
+{
+  for (; chain; chain = TREE_CHAIN (chain))
+    {
+      if (chain == t)
+        return true;
+    }
+  return false;
+}
+
+/* Union a NEWER chain into an EXISTING chain.  */
+
+static void
+pph_union_into_chain (tree *existing, tree newer)
+{
+  /* FIXME pph: A better algorithm would be nice.  */
+  if (newer == NULL)
+    return;
+  if (pph_is_on_chain (*existing, newer))
+      pph_union_into_chain (existing, TREE_CHAIN (newer));
+  else
+    {
+      pph_union_into_chain (existing, TREE_CHAIN (newer));
+      TREE_CHAIN (newer) = *existing;
+      *existing = newer;
+    }
+}
+
 
 /* Read a chain of ASTs from STREAM.  */
 
@@ -2990,9 +3021,7 @@  pph_read_file_1 (pph_stream *stream)
   cpp_ident_use *bad_use;
   const char *cur_def;
   cpp_idents_used idents_used;
-  tree t, file_keyed_classes, file_static_aggregates;
-  unsigned i;
-  VEC(tree,gc) *file_unemitted_tinfo_decls;
+  tree file_static_aggregates;
   source_location cpp_token_replay_loc;
 
   /* If we already have STREAM in memory (or are reading it), ignore
@@ -3042,12 +3071,8 @@  pph_read_file_1 (pph_stream *stream)
 
   /* Read and merge the other global state collected during parsing of
      the original header.  */
-  file_keyed_classes = pph_in_tree (stream);
-  keyed_classes = chainon (file_keyed_classes, keyed_classes);
-
-  file_unemitted_tinfo_decls = pph_in_tree_vec (stream);
-  FOR_EACH_VEC_ELT (tree, file_unemitted_tinfo_decls, i, t)
-    VEC_safe_push (tree, gc, unemitted_tinfo_decls, t);
+  pph_union_into_chain (&keyed_classes, pph_in_tree (stream));
+  pph_union_into_tree_vec (&unemitted_tinfo_decls, pph_in_tree_vec (stream));
 
   pph_in_pending_templates_list (stream);
   pph_in_spec_entry_tables (stream);
@@ -3059,7 +3084,7 @@  pph_read_file_1 (pph_stream *stream)
   pph_in_symtab (stream);
 
   if (flag_pph_dump_tree)
-    pph_dump_namespace (pph_logfile, global_namespace, "after pph read");
+    pph_dump_global_state (pph_logfile, "after pph read");
 }