summaryrefslogtreecommitdiff
path: root/gcc/lto-streamer.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-06 16:49:11 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-06 16:49:11 +0000
commita0605d65f057d09d208c6175c8ef78b8809184da (patch)
tree833ac0df274e1c8def946237e10bd907c5de11ee /gcc/lto-streamer.c
parenta304f2edf185cc84bf2b77515ab3ad104745ba0e (diff)
downloadgcc-a0605d65f057d09d208c6175c8ef78b8809184da.tar.gz
* Makefile.in (lto-compress.o): Add dependency on LTO_STREAMER_H.
(cgraph.o): Likewise. (cgraphunit.o): Likewise. * cgraphunit.c: Include lto-streamer.h (cgraph_finalize_compilation_unit): Call lto_streamer_hooks_init if LTO is enabled. * lto-streamer-in.c (unpack_value_fields): Call streamer_hooks.unpack_value_fields if set. (lto_materialize_tree): For unhandled nodes, first try to call lto_streamer_hooks.alloc_tree, if it exists. (lto_input_ts_decl_common_tree_pointers): Move reading of DECL_INITIAL to lto_streamer_read_tree. (lto_read_tree): Call lto_streamer_hooks.read_tree if set. (lto_streamer_read_tree): New. (lto_reader_init): Rename from lto_init_reader. Move initialization code to lto/lto.c. * lto-streamer-out.c (pack_value_fields): Call streamer_hooks.pack_value_fields if set. (lto_output_tree_ref): For tree nodes that are not normally indexable, call streamer_hooks.indexable_with_decls_p before giving up. (lto_output_ts_decl_common_tree_pointers): Move handling for FUNCTION_DECL and TRANSLATION_UNIT_DECL to lto_streamer_write_tree. (lto_output_tree_header): Call streamer_hooks.is_streamable instead of lto_is_streamable. Call lto_streamer_hooks.output_tree_header if set. (lto_write_tree): Call lto_streamer_hooks.write_tree if set. (lto_streamer_write_tree): New. (lto_output): Call lto_streamer_init directly. (lto_writer_init): Remove. * lto-streamer.c (streamer_hooks): New. (lto_streamer_cache_create): Call streamer_hooks.preload_common_nodes instead of lto_preload_common_nodes. (lto_is_streamable): Move from lto-streamer.h (lto_streamer_hooks_init): New. (streamer_hooks): New. (streamer_hooks_init): New. * lto-streamer.h (struct output_block): Forward declare. (struct lto_input_block): Likewise. (struct data_in): Likewise. (struct bitpack_d): Likewise. (struct streamer_hooks): Declare. (streamer_hooks): Declare. (lto_streamer_hooks_init): Declare. (lto_streamer_write_tree): Declare. (lto_streamer_read_tree): Declare. (streamer_hooks_init): Declare. (lto_is_streamable): Move to lto-streamer.c lto/ChangeLog * lto.c (lto_init): New. (lto_main): Call it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174709 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lto-streamer.c')
-rw-r--r--gcc/lto-streamer.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index 763ecc5e903..0608b33a76b 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -37,6 +37,9 @@ along with GCC; see the file COPYING3. If not see
/* Statistics gathered during LTO, WPA and LTRANS. */
struct lto_stats_d lto_stats;
+/* Streamer hooks. */
+struct streamer_hooks streamer_hooks;
+
/* LTO uses bitmaps with different life-times. So use a seperate
obstack for all LTO bitmaps. */
static bitmap_obstack lto_obstack;
@@ -568,7 +571,7 @@ lto_streamer_cache_create (void)
/* Load all the well-known tree nodes that are always created by
the compiler on startup. This prevents writing them out
unnecessarily. */
- lto_preload_common_nodes (cache);
+ streamer_hooks.preload_common_nodes (cache);
return cache;
}
@@ -713,3 +716,52 @@ lto_check_version (int major, int minor)
major, minor,
LTO_major_version, LTO_minor_version);
}
+
+
+/* Return true if EXPR is a tree node that can be written to disk. */
+static inline bool
+lto_is_streamable (tree expr)
+{
+ enum tree_code code = TREE_CODE (expr);
+
+ /* Notice that we reject SSA_NAMEs as well. We only emit the SSA
+ name version in lto_output_tree_ref (see output_ssa_names). */
+ return !is_lang_specific (expr)
+ && code != SSA_NAME
+ && code != CALL_EXPR
+ && code != LANG_TYPE
+ && code != MODIFY_EXPR
+ && code != INIT_EXPR
+ && code != TARGET_EXPR
+ && code != BIND_EXPR
+ && code != WITH_CLEANUP_EXPR
+ && code != STATEMENT_LIST
+ && code != OMP_CLAUSE
+ && code != OPTIMIZATION_NODE
+ && (code == CASE_LABEL_EXPR
+ || code == DECL_EXPR
+ || TREE_CODE_CLASS (code) != tcc_statement);
+}
+
+
+/* Initialize all the streamer hooks used for streaming GIMPLE. */
+
+void
+lto_streamer_hooks_init (void)
+{
+ streamer_hooks_init ();
+ streamer_hooks.name = "gimple";
+ streamer_hooks.preload_common_nodes = lto_preload_common_nodes;
+ streamer_hooks.is_streamable = lto_is_streamable;
+ streamer_hooks.write_tree = lto_streamer_write_tree;
+ streamer_hooks.read_tree = lto_streamer_read_tree;
+}
+
+
+/* Initialize the current set of streamer hooks. */
+
+void
+streamer_hooks_init (void)
+{
+ memset (&streamer_hooks, 0, sizeof (streamer_hooks));
+}