This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[pph] Save keyed_classes, unemitted_tinfo_decls, TYPE_BINFO (issue4486042)
- From: crowl at google dot com (Lawrence Crowl)
- To: reply at codereview dot appspotmail dot com, dnovillo at google dot com, gcc-patches at gcc dot gnu dot org
- Date: Thu, 5 May 2011 14:30:03 -0700 (PDT)
- Subject: [pph] Save keyed_classes, unemitted_tinfo_decls, TYPE_BINFO (issue4486042)
Save and restored globals keyed_classes and unemitted_tinfo_decls.
Save and restore member TYPE_BINFO.
Index: gcc/cp/ChangeLog.pph
2011-05-05 Lawrence Crowl <crowl@google.com>
* pph.c (pph_write_file_contents): Save keyed_classes and
unemitted_tinfo_decls.
(pph_read_file_contents): Restore keyed_classes and
unemitted_tinfo_decls.
* pph-streamer.h (pph_stream_write_tree_vec): Make extern.
(pph_stream_read_tree_vec): Make extern.
(pph_output_tree_array): Archive for future need.
(pph_output_tree_VEC): Archive for future need.
(pph_input_tree_array): Archive for future need.
(pph_input_tree_VEC): Archive for future need.
* pph-streamer-in.c (pph_stream_read_tree): Make extern.
(pph_stream_read_tree): Restore TYPE_BINFO.
* pph-streamer-out.c (pph_stream_write_tree_vec): Make extern.
(pph_stream_write_tree): Save TYPE_BINFO.
* name-lookup.c (pushdecl_into_namespace): Add leading comment.
Index: gcc/cp/pph.c
===================================================================
--- gcc/cp/pph.c (revision 173407)
+++ gcc/cp/pph.c (working copy)
@@ -1924,6 +1924,8 @@ pph_write_file_contents (pph_stream *str
if (flag_pph_dump_tree)
pph_dump_namespace (pph_logfile, global_namespace);
pph_output_tree (stream, global_namespace, false);
+ pph_output_tree (stream, keyed_classes, false);
+ pph_stream_write_tree_vec (stream, unemitted_tinfo_decls, false);
}
@@ -2048,6 +2050,10 @@ pph_read_file_contents (pph_stream *stre
if (flag_pph_dump_tree)
pph_dump_namespace (pph_logfile, file_ns);
pph_add_names_to_namespace (global_namespace, file_ns);
+ keyed_classes = pph_input_tree (stream);
+ unemitted_tinfo_decls = pph_stream_read_tree_vec (stream);
+ /* FIXME pph: This call replaces the tinfo, we should merge instead.
+ See pph_input_tree_VEC. */
}
Index: gcc/cp/pph-streamer-in.c
===================================================================
--- gcc/cp/pph-streamer-in.c (revision 173407)
+++ gcc/cp/pph-streamer-in.c (working copy)
@@ -226,7 +226,7 @@ pph_stream_read_ld_min (pph_stream *stre
/* Read and return a VEC of trees from STREAM. */
-static VEC(tree,gc) *
+VEC(tree,gc) *
pph_stream_read_tree_vec (pph_stream *stream)
{
unsigned i, num;
@@ -808,5 +808,13 @@ pph_stream_read_tree (struct lto_input_b
}
}
else if (TYPE_P (expr))
- pph_stream_read_lang_type (stream, expr);
+ {
+ pph_stream_read_lang_type (stream, expr);
+ if (TREE_CODE (expr) == RECORD_TYPE
+ || TREE_CODE (expr) == UNION_TYPE
+ || TREE_CODE (expr) == QUAL_UNION_TYPE)
+ {
+ TYPE_BINFO (expr) = pph_input_tree (stream);
+ }
+ }
}
Index: gcc/cp/pph-streamer-out.c
===================================================================
--- gcc/cp/pph-streamer-out.c (revision 173407)
+++ gcc/cp/pph-streamer-out.c (working copy)
@@ -265,7 +265,7 @@ pph_stream_write_ld_min (pph_stream *str
/* Write all the trees in VEC V to STREAM. REF_P is true if the trees should
be written as references. */
-static void
+void
pph_stream_write_tree_vec (pph_stream *stream, VEC(tree,gc) *v, bool ref_p)
{
unsigned i;
@@ -819,7 +819,15 @@ pph_stream_write_tree (struct output_blo
pph_output_tree_or_ref_1 (stream, tsi_stmt (i), ref_p, 3);
}
else if (TYPE_P (expr))
- pph_stream_write_lang_type (stream, expr, ref_p);
+ {
+ pph_stream_write_lang_type (stream, expr, ref_p);
+ if (TREE_CODE (expr) == RECORD_TYPE
+ || TREE_CODE (expr) == UNION_TYPE
+ || TREE_CODE (expr) == QUAL_UNION_TYPE)
+ {
+ pph_output_tree_or_ref_1 (stream, TYPE_BINFO (expr), ref_p, 3);
+ }
+ }
}
Index: gcc/cp/pph-streamer.h
===================================================================
--- gcc/cp/pph-streamer.h (revision 173407)
+++ gcc/cp/pph-streamer.h (working copy)
@@ -103,6 +103,8 @@ void pph_stream_trace_bitpack (pph_strea
/* In pph-streamer-out.c. */
void pph_stream_flush_buffers (pph_stream *);
+void pph_stream_write_tree_vec (pph_stream *stream, VEC(tree,gc) *v,
+ bool ref_p);
void pph_stream_init_write (pph_stream *);
void pph_stream_write_tree (struct output_block *, tree, bool ref_p);
void pph_stream_pack_value_fields (struct bitpack_d *, tree);
@@ -117,6 +119,7 @@ struct binding_table_s *pph_stream_read_
/* In pph-streamer-in.c. */
void pph_stream_init_read (pph_stream *);
+VEC(tree,gc) *pph_stream_read_tree_vec (pph_stream *stream);
void pph_stream_read_tree (struct lto_input_block *, struct data_in *, tree);
void pph_stream_unpack_value_fields (struct bitpack_d *, tree);
tree pph_stream_alloc_tree (enum tree_code, struct lto_input_block *,
@@ -138,6 +141,23 @@ pph_output_tree (pph_stream *stream, tre
lto_output_tree (stream->ob, t, ref_p);
}
+/* Output array A of cardinality C of ASTs to STREAM.
+ If REF_P is true, output all the leaves of T as references. */
+/* FIXME pph: hold for alternate routine. */
+#if 0
+static inline void
+pph_output_tree_array (pph_stream *stream, tree *a, size_t c, bool ref_p)
+{
+ size_t i;
+ for (i = 0; i < c; ++i)
+ {
+ if (flag_pph_tracer >= 1)
+ pph_stream_trace_tree (stream, a[i], ref_p);
+ lto_output_tree (stream->ob, a[i], ref_p);
+ }
+}
+#endif
+
/* Output AST T to STREAM. If REF_P is true, output a reference to T.
If -fpph-tracer is set to TLEVEL or higher, T is sent to
pph_stream_trace_tree. */
@@ -215,6 +235,26 @@ pph_output_string_with_length (pph_strea
}
}
+/* Output VEC V of ASTs to STREAM.
+ If REF_P is true, output all the leaves of T as references. */
+/* FIXME pph: hold for alternate routine. */
+#if 0
+static inline void
+pph_output_tree_VEC (pph_stream *stream, VEC(tree,gc) *v, bool ref_p)
+{
+ tree t;
+ size_t i;
+ size_t c = VEC_length (tree, v);
+ pph_output_uint (stream, c);
+ for (i = 0; VEC_iterate (tree, v, i, t); i++)
+ {
+ if (flag_pph_tracer >= 1)
+ pph_stream_trace_tree (stream, t, ref_p);
+ lto_output_tree (stream->ob, t, ref_p);
+ }
+}
+#endif
+
/* Write a chain of ASTs to STREAM starting with FIRST. REF_P is true
if the nodes should be emitted as references. */
static inline void
@@ -289,6 +329,41 @@ pph_input_tree (pph_stream *stream)
return t;
}
+/* Load into an array A of cardinality C of AST from STREAM. */
+/* FIXME pph: Hold for later use. */
+#if 0
+static inline void
+pph_input_tree_array (pph_stream *stream, tree *a, size_t c)
+{
+ size_t i;
+ for (i = 0; i < c; ++i)
+ {
+ tree t = lto_input_tree (stream->ib, stream->data_in);
+ if (flag_pph_tracer >= 4)
+ pph_stream_trace_tree (stream, t, false); /* FIXME pph: always false? */
+ a[i] = t;
+ }
+}
+#endif
+
+/* Load into a VEC V of AST from STREAM. */
+/* FIXME pph: Hold for later use. */
+#if 0
+static inline void
+pph_input_tree_VEC (pph_stream *stream, VEC(tree,gc) *v)
+{
+ size_t i;
+ unsigned int c = pph_input_uint (stream);
+ for (i = 0; i < c; ++i)
+ {
+ tree t = lto_input_tree (stream->ib, stream->data_in);
+ if (flag_pph_tracer >= 4)
+ pph_stream_trace_tree (stream, t, false); /* FIXME pph: always false? */
+ VEC_safe_push (tree, gc, v, t);
+ }
+}
+#endif
+
/* Read a chain of ASTs from STREAM. */
static inline tree
pph_input_chain (pph_stream *stream)
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c (revision 173407)
+++ gcc/cp/name-lookup.c (working copy)
@@ -1181,6 +1181,12 @@ pushdecl_maybe_friend (tree x, bool is_f
return ret;
}
+/* Record a decl-node DCL as belonging to the namespace NSP.
+
+ Returns either DCL or an old decl for the same name.
+ If an old decl is returned, it may have been smashed
+ to agree with what DCL says. */
+
tree
pushdecl_into_namespace (tree dcl, tree nsp)
{
--
This patch is available for review at http://codereview.appspot.com/4486042