Commit ac0511f2 by Richard Biener Committed by Richard Biener

tree-streamer.h (streamer_tree_cache_create): Adjust prototype.

2013-06-18  Richard Biener  <rguenther@suse.de>

	* tree-streamer.h (streamer_tree_cache_create): Adjust prototype.
	* tree-streamer.c (streamer_tree_cache_create): Make maintaining
	the map from cache entry to cache index optional.
	(streamer_tree_cache_replace_tree): Adjust accordingly.
	(streamer_tree_cache_append): Likewise.
	(streamer_tree_cache_delete): Likewise.
	* lto-streamer-in.c (lto_data_in_create): Do not maintain the
	streamer cache map from cache entry to cache index.
	* lto-streamer-out.c (create_output_block): Adjust.

	lto/
	* lto.c (lto_register_var_decl_in_symtab): Pass in cache index
	and use it.
	(lto_register_function_decl_in_symtab): Likewise.
	(cmp_tree): New function.
	(unify_scc): Instead of using the streamer cache map from entry
	to cache index match up the two maps we have by sorting them.
	Adjust calls to lto_register_var_decl_in_symtab and
	lto_register_function_decl_in_symtab.

From-SVN: r200168
parent 09485a08
2013-06-18 Richard Biener <rguenther@suse.de>
* tree-streamer.h (streamer_tree_cache_create): Adjust prototype.
* tree-streamer.c (streamer_tree_cache_create): Make maintaining
the map from cache entry to cache index optional.
(streamer_tree_cache_replace_tree): Adjust accordingly.
(streamer_tree_cache_append): Likewise.
(streamer_tree_cache_delete): Likewise.
* lto-streamer-in.c (lto_data_in_create): Do not maintain the
streamer cache map from cache entry to cache index.
* lto-streamer-out.c (create_output_block): Adjust.
2013-06-18 Sofiane Naci <sofiane.naci@arm.com> 2013-06-18 Sofiane Naci <sofiane.naci@arm.com>
* config/arm/arm.md (attribute "insn"): Move multiplication and division * config/arm/arm.md (attribute "insn"): Move multiplication and division
......
...@@ -1305,7 +1305,7 @@ lto_data_in_create (struct lto_file_decl_data *file_data, const char *strings, ...@@ -1305,7 +1305,7 @@ lto_data_in_create (struct lto_file_decl_data *file_data, const char *strings,
data_in->strings = strings; data_in->strings = strings;
data_in->strings_len = len; data_in->strings_len = len;
data_in->globals_resolution = resolutions; data_in->globals_resolution = resolutions;
data_in->reader_cache = streamer_tree_cache_create (false); data_in->reader_cache = streamer_tree_cache_create (false, false);
return data_in; return data_in;
} }
......
...@@ -71,7 +71,7 @@ create_output_block (enum lto_section_type section_type) ...@@ -71,7 +71,7 @@ create_output_block (enum lto_section_type section_type)
ob->decl_state = lto_get_out_decl_state (); ob->decl_state = lto_get_out_decl_state ();
ob->main_stream = XCNEW (struct lto_output_stream); ob->main_stream = XCNEW (struct lto_output_stream);
ob->string_stream = XCNEW (struct lto_output_stream); ob->string_stream = XCNEW (struct lto_output_stream);
ob->writer_cache = streamer_tree_cache_create (!flag_wpa); ob->writer_cache = streamer_tree_cache_create (!flag_wpa, true);
if (section_type == LTO_section_function_body) if (section_type == LTO_section_function_body)
ob->cfg_stream = XCNEW (struct lto_output_stream); ob->cfg_stream = XCNEW (struct lto_output_stream);
......
2013-06-18 Richard Biener <rguenther@suse.de>
* lto.c (lto_register_var_decl_in_symtab): Pass in cache index
and use it.
(lto_register_function_decl_in_symtab): Likewise.
(cmp_tree): New function.
(unify_scc): Instead of using the streamer cache map from entry
to cache index match up the two maps we have by sorting them.
Adjust calls to lto_register_var_decl_in_symtab and
lto_register_function_decl_in_symtab.
2013-06-17 Richard Biener <rguenther@suse.de> 2013-06-17 Richard Biener <rguenther@suse.de>
* Make-lang.in (lto.o): Add $(DATA_STREAMER_H) dependency. * Make-lang.in (lto.o): Add $(DATA_STREAMER_H) dependency.
......
...@@ -1608,7 +1608,8 @@ register_resolution (struct lto_file_decl_data *file_data, tree decl, ...@@ -1608,7 +1608,8 @@ register_resolution (struct lto_file_decl_data *file_data, tree decl,
different files. */ different files. */
static void static void
lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl) lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl,
unsigned ix)
{ {
tree context; tree context;
...@@ -1616,19 +1617,13 @@ lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl) ...@@ -1616,19 +1617,13 @@ lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl)
if (!TREE_PUBLIC (decl) if (!TREE_PUBLIC (decl)
&& !((context = decl_function_context (decl)) && !((context = decl_function_context (decl))
&& auto_var_in_fn_p (decl, context))) && auto_var_in_fn_p (decl, context)))
{ rest_of_decl_compilation (decl, 1, 0);
rest_of_decl_compilation (decl, 1, 0);
}
/* If this variable has already been declared, queue the /* If this variable has already been declared, queue the
declaration for merging. */ declaration for merging. */
if (TREE_PUBLIC (decl)) if (TREE_PUBLIC (decl))
{ register_resolution (data_in->file_data,
unsigned ix; decl, get_resolution (data_in, ix));
if (!streamer_tree_cache_lookup (data_in->reader_cache, decl, &ix))
gcc_unreachable ();
register_resolution (data_in->file_data, decl, get_resolution (data_in, ix));
}
} }
...@@ -1638,17 +1633,14 @@ lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl) ...@@ -1638,17 +1633,14 @@ lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl)
file being read. */ file being read. */
static void static void
lto_register_function_decl_in_symtab (struct data_in *data_in, tree decl) lto_register_function_decl_in_symtab (struct data_in *data_in, tree decl,
unsigned ix)
{ {
/* If this variable has already been declared, queue the /* If this variable has already been declared, queue the
declaration for merging. */ declaration for merging. */
if (TREE_PUBLIC (decl) && !DECL_ABSTRACT (decl)) if (TREE_PUBLIC (decl) && !DECL_ABSTRACT (decl))
{ register_resolution (data_in->file_data,
unsigned ix; decl, get_resolution (data_in, ix));
if (!streamer_tree_cache_lookup (data_in->reader_cache, decl, &ix))
gcc_unreachable ();
register_resolution (data_in->file_data, decl, get_resolution (data_in, ix));
}
} }
...@@ -2259,6 +2251,19 @@ compare_tree_sccs (tree_scc *pscc, tree_scc *scc, ...@@ -2259,6 +2251,19 @@ compare_tree_sccs (tree_scc *pscc, tree_scc *scc,
return false; return false;
} }
/* QSort sort function to sort a map of two pointers after the 2nd
pointer. */
static int
cmp_tree (const void *p1_, const void *p2_)
{
tree *p1 = (tree *)(const_cast<void *>(p1_));
tree *p2 = (tree *)(const_cast<void *>(p2_));
if (p1[1] == p2[1])
return 0;
return ((uintptr_t)p1[1] < (uintptr_t)p2[1]) ? -1 : 1;
}
/* Try to unify the SCC with nodes FROM to FROM + LEN in CACHE and /* Try to unify the SCC with nodes FROM to FROM + LEN in CACHE and
hash value SCC_HASH with an already recorded SCC. Return true if hash value SCC_HASH with an already recorded SCC. Return true if
that was successful, otherwise return false. */ that was successful, otherwise return false. */
...@@ -2323,29 +2328,47 @@ unify_scc (struct streamer_tree_cache_d *cache, unsigned from, ...@@ -2323,29 +2328,47 @@ unify_scc (struct streamer_tree_cache_d *cache, unsigned from,
num_sccs_merged++; num_sccs_merged++;
total_scc_size_merged += len; total_scc_size_merged += len;
/* Fixup the streamer cache with the prevailing nodes according #ifdef ENABLE_CHECKING
to the tree node mapping computed by compare_tree_sccs. */
for (unsigned i = 0; i < len; ++i) for (unsigned i = 0; i < len; ++i)
{ {
tree t = map[2*i+1]; tree t = map[2*i+1];
enum tree_code code = TREE_CODE (t); enum tree_code code = TREE_CODE (t);
unsigned ix;
bool r;
/* IDENTIFIER_NODEs should be singletons and are merged by the /* IDENTIFIER_NODEs should be singletons and are merged by the
streamer. The others should be singletons, too, and we streamer. The others should be singletons, too, and we
should not merge them in any way. */ should not merge them in any way. */
gcc_assert (code != TRANSLATION_UNIT_DECL gcc_assert (code != TRANSLATION_UNIT_DECL
&& code != IDENTIFIER_NODE && code != IDENTIFIER_NODE
&& !streamer_handle_as_builtin_p (t)); && !streamer_handle_as_builtin_p (t));
r = streamer_tree_cache_lookup (cache, t, &ix);
gcc_assert (r && ix >= from);
streamer_tree_cache_replace_tree (cache, map[2 * i], ix);
if (TYPE_P (t))
num_merged_types++;
} }
#endif
/* Fixup the streamer cache with the prevailing nodes according
to the tree node mapping computed by compare_tree_sccs. */
if (len == 1)
streamer_tree_cache_replace_tree (cache, pscc->entries[0], from);
else
{
tree *map2 = XALLOCAVEC (tree, 2 * len);
for (unsigned i = 0; i < len; ++i)
{
map2[i*2] = (tree)(uintptr_t)(from + i);
map2[i*2+1] = scc->entries[i];
}
qsort (map2, len, 2 * sizeof (tree), cmp_tree);
qsort (map, len, 2 * sizeof (tree), cmp_tree);
for (unsigned i = 0; i < len; ++i)
streamer_tree_cache_replace_tree (cache, map[2*i],
(uintptr_t)map2[2*i]);
}
/* Free the tree nodes from the read SCC. */ /* Free the tree nodes from the read SCC. */
for (unsigned i = 0; i < len; ++i) for (unsigned i = 0; i < len; ++i)
ggc_free (scc->entries[i]); {
if (TYPE_P (scc->entries[i]))
num_merged_types++;
ggc_free (scc->entries[i]);
}
break; break;
} }
...@@ -2493,10 +2516,10 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, ...@@ -2493,10 +2516,10 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data,
/* Register variables and functions with the /* Register variables and functions with the
symbol table. */ symbol table. */
if (TREE_CODE (t) == VAR_DECL) if (TREE_CODE (t) == VAR_DECL)
lto_register_var_decl_in_symtab (data_in, t); lto_register_var_decl_in_symtab (data_in, t, from + i);
else if (TREE_CODE (t) == FUNCTION_DECL else if (TREE_CODE (t) == FUNCTION_DECL
&& !DECL_BUILT_IN (t)) && !DECL_BUILT_IN (t))
lto_register_function_decl_in_symtab (data_in, t); lto_register_function_decl_in_symtab (data_in, t, from + i);
/* Scan the tree for references to global functions or /* Scan the tree for references to global functions or
variables and record those for later fixup. */ variables and record those for later fixup. */
maybe_remember_with_vars (t); maybe_remember_with_vars (t);
......
...@@ -197,7 +197,10 @@ streamer_tree_cache_replace_tree (struct streamer_tree_cache_d *cache, ...@@ -197,7 +197,10 @@ streamer_tree_cache_replace_tree (struct streamer_tree_cache_d *cache,
hashval_t hash = 0; hashval_t hash = 0;
if (cache->hashes.exists ()) if (cache->hashes.exists ())
hash = streamer_tree_cache_get_hash (cache, ix); hash = streamer_tree_cache_get_hash (cache, ix);
streamer_tree_cache_insert_1 (cache, t, hash, &ix, false); if (!cache->node_map)
streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
else
streamer_tree_cache_insert_1 (cache, t, hash, &ix, false);
} }
...@@ -208,7 +211,10 @@ streamer_tree_cache_append (struct streamer_tree_cache_d *cache, ...@@ -208,7 +211,10 @@ streamer_tree_cache_append (struct streamer_tree_cache_d *cache,
tree t, hashval_t hash) tree t, hashval_t hash)
{ {
unsigned ix = cache->nodes.length (); unsigned ix = cache->nodes.length ();
streamer_tree_cache_insert_1 (cache, t, hash, &ix, false); if (!cache->node_map)
streamer_tree_cache_add_to_node_array (cache, ix, t, hash);
else
streamer_tree_cache_insert_1 (cache, t, hash, &ix, false);
} }
/* Return true if tree node T exists in CACHE, otherwise false. If IX_P is /* Return true if tree node T exists in CACHE, otherwise false. If IX_P is
...@@ -319,13 +325,14 @@ preload_common_nodes (struct streamer_tree_cache_d *cache) ...@@ -319,13 +325,14 @@ preload_common_nodes (struct streamer_tree_cache_d *cache)
/* Create a cache of pickled nodes. */ /* Create a cache of pickled nodes. */
struct streamer_tree_cache_d * struct streamer_tree_cache_d *
streamer_tree_cache_create (bool with_hashes) streamer_tree_cache_create (bool with_hashes, bool with_map)
{ {
struct streamer_tree_cache_d *cache; struct streamer_tree_cache_d *cache;
cache = XCNEW (struct streamer_tree_cache_d); cache = XCNEW (struct streamer_tree_cache_d);
cache->node_map = pointer_map_create (); if (with_map)
cache->node_map = pointer_map_create ();
cache->nodes.create (165); cache->nodes.create (165);
if (with_hashes) if (with_hashes)
cache->hashes.create (165); cache->hashes.create (165);
...@@ -347,7 +354,8 @@ streamer_tree_cache_delete (struct streamer_tree_cache_d *c) ...@@ -347,7 +354,8 @@ streamer_tree_cache_delete (struct streamer_tree_cache_d *c)
if (c == NULL) if (c == NULL)
return; return;
pointer_map_destroy (c->node_map); if (c->node_map)
pointer_map_destroy (c->node_map);
c->nodes.release (); c->nodes.release ();
c->hashes.release (); c->hashes.release ();
free (c); free (c);
......
...@@ -98,7 +98,7 @@ void streamer_tree_cache_append (struct streamer_tree_cache_d *, tree, ...@@ -98,7 +98,7 @@ void streamer_tree_cache_append (struct streamer_tree_cache_d *, tree,
hashval_t); hashval_t);
bool streamer_tree_cache_lookup (struct streamer_tree_cache_d *, tree, bool streamer_tree_cache_lookup (struct streamer_tree_cache_d *, tree,
unsigned *); unsigned *);
struct streamer_tree_cache_d *streamer_tree_cache_create (bool); struct streamer_tree_cache_d *streamer_tree_cache_create (bool, bool);
void streamer_tree_cache_delete (struct streamer_tree_cache_d *); void streamer_tree_cache_delete (struct streamer_tree_cache_d *);
/* Return the tree node at slot IX in CACHE. */ /* Return the tree node at slot IX in CACHE. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment