cgraph.h (struct symtab_node): Add field in_init_priority_hash (set_init_priority...

* cgraph.h (struct symtab_node): Add field in_init_priority_hash
	(set_init_priority, get_init_priority, set_fini_priority,
	get_fini_priority): New methods.
	* tree.c (init_priority_for_decl): Remove.
	(init_ttree): Do not initialize init priority.
	(decl_init_priority_lookup, decl_fini_priority_lookup): Rewrite.
	(decl_priority_info): Remove.
	(decl_init_priority_insert): Rewrite.
	(decl_fini_priority_insert): Rewrite.
	* tree.h (tree_priority_map_eq, tree_priority_map_hash,
	tree_priority_map_marked_p): Remove.
	* lto-cgraph.c (lto_output_node, input_node): Stream init priorities.
	* lto-streamer-out.c (hash_tree): Do not hash priorities.
	* tree-streamer-out.c (pack_ts_decl_with_vis_value_fields): Do
	not output priorities.
	(pack_ts_function_decl_value_fields): Likewise.
	* tree-streamer-in.c (unpack_ts_decl_with_vis_value_fields): Do
	not input priorities.
	(unpack_ts_function_decl_value_fields): Likewise.
	* symtab.c (symbol_priority_map): Declare.
	(init_priority_hash): Declare.
	(symtab_unregister_node): Unregister from priority hash, too.
	(symtab_node::get_init_priority, cgraph_node::get_fini_priority):
	New methods.
	(symbol_priority_map_eq, symbol_priority_map_hash): New functions.
	(symbol_priority_info): New function.
	(symtab_node::set_init_priority, cgraph_node::set_fini_priority):
	New methods.
	* tree-core.h (tree_priority_map): Remove.

	* lto.c (compare_tree_sccs_1): Do not compare priorities.

From-SVN: r211838
This commit is contained in:
Jan Hubicka 2014-06-20 09:09:27 +02:00 committed by Jan Hubicka
parent 88f5cfcd2b
commit 569b1784fe
12 changed files with 220 additions and 89 deletions

View File

@ -1,3 +1,35 @@
2014-06-20 Jan Hubicka <hubicka@ucw.cz>
* cgraph.h (struct symtab_node): Add field in_init_priority_hash
(set_init_priority, get_init_priority, set_fini_priority,
get_fini_priority): New methods.
* tree.c (init_priority_for_decl): Remove.
(init_ttree): Do not initialize init priority.
(decl_init_priority_lookup, decl_fini_priority_lookup): Rewrite.
(decl_priority_info): Remove.
(decl_init_priority_insert): Rewrite.
(decl_fini_priority_insert): Rewrite.
* tree.h (tree_priority_map_eq, tree_priority_map_hash,
tree_priority_map_marked_p): Remove.
* lto-cgraph.c (lto_output_node, input_node): Stream init priorities.
* lto-streamer-out.c (hash_tree): Do not hash priorities.
* tree-streamer-out.c (pack_ts_decl_with_vis_value_fields): Do
not output priorities.
(pack_ts_function_decl_value_fields): Likewise.
* tree-streamer-in.c (unpack_ts_decl_with_vis_value_fields): Do
not input priorities.
(unpack_ts_function_decl_value_fields): Likewise.
* symtab.c (symbol_priority_map): Declare.
(init_priority_hash): Declare.
(symtab_unregister_node): Unregister from priority hash, too.
(symtab_node::get_init_priority, cgraph_node::get_fini_priority):
New methods.
(symbol_priority_map_eq, symbol_priority_map_hash): New functions.
(symbol_priority_info): New function.
(symtab_node::set_init_priority, cgraph_node::set_fini_priority):
New methods.
* tree-core.h (tree_priority_map): Remove.
2014-06-20 Jakub Jelinek <jakub@redhat.com>
* tree-ssa-math-opts.c (do_shift_rotate, find_bswap_or_nop_1): Cast

View File

@ -130,6 +130,8 @@ public:
/* Set when symbol has address taken. */
unsigned address_taken : 1;
/* Set when init priority is set. */
unsigned in_init_priority_hash : 1;
/* Ordering of all symtab entries. */
@ -163,6 +165,7 @@ public:
return x_comdat_group;
}
/* Return comdat group as identifier_node. */
tree get_comdat_group_id ()
{
if (x_comdat_group && TREE_CODE (x_comdat_group) != IDENTIFIER_NODE)
@ -208,6 +211,9 @@ public:
/* Set section for symbol and its aliases. */
void set_section (const char *section);
void set_section_for_node (const char *section);
void set_init_priority (priority_type priority);
priority_type get_init_priority ();
};
enum availability
@ -497,6 +503,9 @@ public:
/* True if this decl calls a COMDAT-local function. This is set up in
compute_inline_parameters and inline_call. */
unsigned calls_comdat_local : 1;
void set_fini_priority (priority_type priority);
priority_type get_fini_priority ();
};

View File

@ -557,6 +557,10 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
streamer_write_uhwi_stream (ob->main_stream, node->thunk.virtual_value);
}
streamer_write_hwi_stream (ob->main_stream, node->profile_id);
if (DECL_STATIC_CONSTRUCTOR (node->decl))
streamer_write_hwi_stream (ob->main_stream, DECL_INIT_PRIORITY (node->decl));
if (DECL_STATIC_DESTRUCTOR (node->decl))
streamer_write_hwi_stream (ob->main_stream, DECL_FINI_PRIORITY (node->decl));
}
/* Output the varpool NODE to OB.
@ -1210,6 +1214,10 @@ input_node (struct lto_file_decl_data *file_data,
if (node->alias && !node->analyzed && node->weakref)
node->alias_target = get_alias_symbol (node->decl);
node->profile_id = streamer_read_hwi (ib);
if (DECL_STATIC_CONSTRUCTOR (node->decl))
SET_DECL_INIT_PRIORITY (node->decl, streamer_read_hwi (ib));
if (DECL_STATIC_DESTRUCTOR (node->decl))
SET_DECL_FINI_PRIORITY (node->decl, streamer_read_hwi (ib));
return node;
}

View File

@ -827,8 +827,6 @@ hash_tree (struct streamer_tree_cache_d *cache, tree t)
| (DECL_CXX_CONSTRUCTOR_P (t) << 1)
| (DECL_CXX_DESTRUCTOR_P (t) << 2),
v);
if (VAR_OR_FUNCTION_DECL_P (t))
v = iterative_hash_host_wide_int (DECL_INIT_PRIORITY (t), v);
}
if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
@ -852,8 +850,6 @@ hash_tree (struct streamer_tree_cache_d *cache, tree t)
| (DECL_LOOPING_CONST_OR_PURE_P (t) << 15), v);
if (DECL_BUILT_IN_CLASS (t) != NOT_BUILT_IN)
v = iterative_hash_host_wide_int (DECL_FUNCTION_CODE (t), v);
if (DECL_STATIC_DESTRUCTOR (t))
v = iterative_hash_host_wide_int (DECL_FINI_PRIORITY (t), v);
}
if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))

View File

@ -1,3 +1,7 @@
2014-06-20 Jan Hubicka <hubicka@ucw.cz>
* lto.c (compare_tree_sccs_1): Do not compare priorities.
2014-06-15 Jan Hubicka <hubicka@ucw.cz>
* lto.c (compare_tree_sccs_1): Do not compare DECL_TLS_MODEL.

View File

@ -1300,8 +1300,6 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
/* DECL_IN_TEXT_SECTION is set during final asm output only. */
compare_values (DECL_IN_CONSTANT_POOL);
}
if (VAR_OR_FUNCTION_DECL_P (t1))
compare_values (DECL_INIT_PRIORITY);
}
if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
@ -1328,8 +1326,6 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
compare_values (DECL_CXX_DESTRUCTOR_P);
if (DECL_BUILT_IN_CLASS (t1) != NOT_BUILT_IN)
compare_values (DECL_FUNCTION_CODE);
if (DECL_STATIC_DESTRUCTOR (t1))
compare_values (DECL_FINI_PRIORITY);
}
if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))

View File

@ -64,6 +64,17 @@ static GTY((param_is (section_hash_entry))) htab_t section_hash;
/* Hash table used to convert assembler names into nodes. */
static GTY((param_is (symtab_node))) htab_t assembler_name_hash;
/* Map from a symbol to initialization/finalization priorities. */
struct GTY(()) symbol_priority_map {
symtab_node *symbol;
priority_type init;
priority_type fini;
};
/* Hash table used to hold init priorities. */
static GTY ((param_is (struct symbol_priority_map)))
htab_t init_priority_hash;
/* Linked list of symbol table nodes. */
symtab_node *symtab_nodes;
@ -337,6 +348,16 @@ symtab_unregister_node (symtab_node *node)
}
if (!is_a <varpool_node *> (node) || !DECL_HARD_REGISTER (node->decl))
unlink_from_assembler_name_hash (node, false);
if (node->in_init_priority_hash)
{
struct symbol_priority_map in;
void **slot;
in.symbol = node;
slot = htab_find_slot (init_priority_hash, &in, NO_INSERT);
if (slot)
htab_clear_slot (init_priority_hash, slot);
}
}
@ -1176,6 +1197,122 @@ symtab_node::set_section (const char *section)
symtab_for_node_and_aliases (this, set_section_1, const_cast<char *>(section), true);
}
/* Return the initialization priority. */
priority_type
symtab_node::get_init_priority ()
{
struct symbol_priority_map *h;
struct symbol_priority_map in;
if (!this->in_init_priority_hash)
return DEFAULT_INIT_PRIORITY;
in.symbol = this;
h = (struct symbol_priority_map *) htab_find (init_priority_hash, &in);
return h ? h->init : DEFAULT_INIT_PRIORITY;
}
/* Return the finalization priority. */
priority_type
cgraph_node::get_fini_priority ()
{
struct symbol_priority_map *h;
struct symbol_priority_map in;
if (!this->in_init_priority_hash)
return DEFAULT_INIT_PRIORITY;
in.symbol = this;
h = (struct symbol_priority_map *) htab_find (init_priority_hash, &in);
return h ? h->fini : DEFAULT_INIT_PRIORITY;
}
/* Return true if the from tree in both priority maps are equal. */
int
symbol_priority_map_eq (const void *va, const void *vb)
{
const struct symbol_priority_map *const a = (const struct symbol_priority_map *) va,
*const b = (const struct symbol_priority_map *) vb;
return (a->symbol == b->symbol);
}
/* Hash a from symbol in a symbol_priority_map. */
unsigned int
symbol_priority_map_hash (const void *item)
{
return htab_hash_pointer (((const struct symbol_priority_map *)item)->symbol);
}
/* Return the initialization and finalization priority information for
DECL. If there is no previous priority information, a freshly
allocated structure is returned. */
static struct symbol_priority_map *
symbol_priority_info (struct symtab_node *symbol)
{
struct symbol_priority_map in;
struct symbol_priority_map *h;
void **loc;
in.symbol = symbol;
if (!init_priority_hash)
init_priority_hash = htab_create_ggc (512, symbol_priority_map_hash,
symbol_priority_map_eq, 0);
loc = htab_find_slot (init_priority_hash, &in, INSERT);
h = (struct symbol_priority_map *) *loc;
if (!h)
{
h = ggc_cleared_alloc<symbol_priority_map> ();
*loc = h;
h->symbol = symbol;
h->init = DEFAULT_INIT_PRIORITY;
h->fini = DEFAULT_INIT_PRIORITY;
symbol->in_init_priority_hash = true;
}
return h;
}
/* Set initialization priority to PRIORITY. */
void
symtab_node::set_init_priority (priority_type priority)
{
struct symbol_priority_map *h;
if (is_a <cgraph_node *> (this))
gcc_assert (DECL_STATIC_CONSTRUCTOR (this->decl));
if (priority == DEFAULT_INIT_PRIORITY)
{
gcc_assert (get_init_priority() == priority);
return;
}
h = symbol_priority_info (this);
h->init = priority;
}
/* Set fialization priority to PRIORITY. */
void
cgraph_node::set_fini_priority (priority_type priority)
{
struct symbol_priority_map *h;
gcc_assert (DECL_STATIC_DESTRUCTOR (this->decl));
if (priority == DEFAULT_INIT_PRIORITY)
{
gcc_assert (get_fini_priority() == priority);
return;
}
h = symbol_priority_info (this);
h->fini = priority;
}
/* Worker for symtab_resolve_alias. */
static bool

View File

@ -1761,13 +1761,6 @@ struct GTY(()) tree_int_map {
unsigned int to;
};
/* Map from a tree to initialization/finalization priorities. */
struct GTY(()) tree_priority_map {
struct tree_map_base base;
priority_type init;
priority_type fini;
};
/* Map from a decl tree to a tree vector. */
struct GTY(()) tree_vec_map {
struct tree_map_base base;

View File

@ -288,12 +288,6 @@ unpack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
DECL_CXX_CONSTRUCTOR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
DECL_CXX_DESTRUCTOR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
}
if (VAR_OR_FUNCTION_DECL_P (expr))
{
priority_type p;
p = (priority_type) bp_unpack_var_len_unsigned (bp);
SET_DECL_INIT_PRIORITY (expr, p);
}
}
@ -336,12 +330,6 @@ unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
fatal_error ("target specific builtin not available");
}
}
if (DECL_STATIC_DESTRUCTOR (expr))
{
priority_type p;
p = (priority_type) bp_unpack_var_len_unsigned (bp);
SET_DECL_FINI_PRIORITY (expr, p);
}
}

View File

@ -256,8 +256,6 @@ pack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
bp_pack_value (bp, DECL_CXX_CONSTRUCTOR_P (expr), 1);
bp_pack_value (bp, DECL_CXX_DESTRUCTOR_P (expr), 1);
}
if (VAR_OR_FUNCTION_DECL_P (expr))
bp_pack_var_len_unsigned (bp, DECL_INIT_PRIORITY (expr));
}
@ -291,8 +289,6 @@ pack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
bp_pack_value (bp, DECL_LOOPING_CONST_OR_PURE_P (expr), 1);
if (DECL_BUILT_IN_CLASS (expr) != NOT_BUILT_IN)
bp_pack_value (bp, DECL_FUNCTION_CODE (expr), 11);
if (DECL_STATIC_DESTRUCTOR (expr))
bp_pack_var_len_unsigned (bp, DECL_FINI_PRIORITY (expr));
}

View File

@ -219,10 +219,6 @@ static GTY ((if_marked ("tree_decl_map_marked_p"), param_is (struct tree_decl_ma
static GTY ((if_marked ("tree_vec_map_marked_p"), param_is (struct tree_vec_map)))
htab_t debug_args_for_decl;
static GTY ((if_marked ("tree_priority_map_marked_p"),
param_is (struct tree_priority_map)))
htab_t init_priority_for_decl;
static void set_type_quals (tree, int);
static int type_hash_eq (const void *, const void *);
static hashval_t type_hash_hash (const void *);
@ -573,8 +569,6 @@ init_ttree (void)
value_expr_for_decl = htab_create_ggc (512, tree_decl_map_hash,
tree_decl_map_eq, 0);
init_priority_for_decl = htab_create_ggc (512, tree_priority_map_hash,
tree_priority_map_eq, 0);
int_cst_hash_table = htab_create_ggc (1024, int_cst_hash_hash,
int_cst_hash_eq, NULL);
@ -6492,13 +6486,12 @@ tree_decl_map_hash (const void *item)
priority_type
decl_init_priority_lookup (tree decl)
{
struct tree_priority_map *h;
struct tree_map_base in;
symtab_node *snode = symtab_get_node (decl);
gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
in.from = decl;
h = (struct tree_priority_map *) htab_find (init_priority_for_decl, &in);
return h ? h->init : DEFAULT_INIT_PRIORITY;
if (!snode)
return DEFAULT_INIT_PRIORITY;
return
snode->get_init_priority ();
}
/* Return the finalization priority for DECL. */
@ -6506,39 +6499,12 @@ decl_init_priority_lookup (tree decl)
priority_type
decl_fini_priority_lookup (tree decl)
{
struct tree_priority_map *h;
struct tree_map_base in;
cgraph_node *node = cgraph_get_node (decl);
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
in.from = decl;
h = (struct tree_priority_map *) htab_find (init_priority_for_decl, &in);
return h ? h->fini : DEFAULT_INIT_PRIORITY;
}
/* Return the initialization and finalization priority information for
DECL. If there is no previous priority information, a freshly
allocated structure is returned. */
static struct tree_priority_map *
decl_priority_info (tree decl)
{
struct tree_priority_map in;
struct tree_priority_map *h;
void **loc;
in.base.from = decl;
loc = htab_find_slot (init_priority_for_decl, &in, INSERT);
h = (struct tree_priority_map *) *loc;
if (!h)
{
h = ggc_cleared_alloc<tree_priority_map> ();
*loc = h;
h->base.from = decl;
h->init = DEFAULT_INIT_PRIORITY;
h->fini = DEFAULT_INIT_PRIORITY;
}
return h;
if (!node)
return DEFAULT_INIT_PRIORITY;
return
node->get_fini_priority ();
}
/* Set the initialization priority for DECL to PRIORITY. */
@ -6546,13 +6512,19 @@ decl_priority_info (tree decl)
void
decl_init_priority_insert (tree decl, priority_type priority)
{
struct tree_priority_map *h;
struct symtab_node *snode;
gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
if (priority == DEFAULT_INIT_PRIORITY)
return;
h = decl_priority_info (decl);
h->init = priority;
{
snode = symtab_get_node (decl);
if (!snode)
return;
}
else if (TREE_CODE (decl) == VAR_DECL)
snode = varpool_node_for_decl (decl);
else
snode = cgraph_get_create_node (decl);
snode->set_init_priority (priority);
}
/* Set the finalization priority for DECL to PRIORITY. */
@ -6560,13 +6532,17 @@ decl_init_priority_insert (tree decl, priority_type priority)
void
decl_fini_priority_insert (tree decl, priority_type priority)
{
struct tree_priority_map *h;
struct cgraph_node *node;
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
if (priority == DEFAULT_INIT_PRIORITY)
return;
h = decl_priority_info (decl);
h->fini = priority;
{
node = cgraph_get_node (decl);
if (!node)
return;
}
else
node = cgraph_get_create_node (decl);
node->set_fini_priority (priority);
}
/* Print out the statistics for the DECL_DEBUG_EXPR hash table. */

View File

@ -4345,10 +4345,6 @@ extern unsigned int tree_decl_map_hash (const void *);
#define tree_int_map_hash tree_map_base_hash
#define tree_int_map_marked_p tree_map_base_marked_p
#define tree_priority_map_eq tree_map_base_eq
#define tree_priority_map_hash tree_map_base_hash
#define tree_priority_map_marked_p tree_map_base_marked_p
#define tree_vec_map_eq tree_map_base_eq
#define tree_vec_map_hash tree_decl_map_hash
#define tree_vec_map_marked_p tree_map_base_marked_p