Commit 7b99cca4 by Jan Hubicka Committed by Jan Hubicka

Replace cgraph_node_set and varpool_node_set by symtab_node_encoder in partitioning.



	Replace cgraph_node_set and varpool_node_set by symtab_node_encoder
	in partitioning.
	* tree-pass.h (cgraph_node_set_def, varpool_node_set_def): Remove
	forward declaration.
	(lto_symtab_encoder_d): Forward declare.
	(ipa_write_optimization_summaries): Update.
	* lto-cgraph.c (lto_symtab_encoder_new): Do not initialize
	body, initializer and in_partition.
	(lto_symtab_encoder_delete): Update.
	(lto_symtab_encoder_encode): Update.
	(lto_symtab_encoder_lookup): Move inline.
	(lto_symtab_encoder_delete_node): New function.
	(lto_symtab_encoder_encode_body_p, lto_set_symtab_encoder_encode_body,
	lto_symtab_encoder_encode_initializer_p,
	lto_set_symtab_encoder_encode_initializer, lto_symtab_encoder_in_partition_p,
	lto_symtab_encoder_in_partition_p): Update.
	(compute_ltrans_boundary): Take encoder as an input.
	* passes.c (ipa_write_summaries_1): Update.
	(ipa_write_summaries_1): Update.
	(ipa_write_summaries): Update.
	(ipa_write_optimization_summaries): Update.
	* lto-streamer.c (print_lto_report): Report number of cgraph nodes.
	* lto-streamer.h (lto_stats_d): Replace num_output_cgraph_nodes by
	num_output_symtab_nodes.
	(lto_encoder_entry): New structure.
	(struct lto_symtab_encoder_d): Reorg.
	(lto_symtab_encoder_delete_node): Declare.
	(lto_symtab_encoder_lookup): Bring inline.
	(compute_ltrans_boundary): Update.
	(lto_symtab_encoder_size): Update.
	(lsei_node, lsei_cgraph_node, lsei_varpool_node): Update.
	(lto_symtab_encoder_deref): Update.

	Replace cgraph_node_set and varpool_node_set by symtab_node_encoder
	in partitioning.
	* lto-partition.h (ltrans_partition_def): Replace cgraph_set and varpool_set
	by encoder.
	* lto-partition.c (new_partition): Update.
	* lto.c (cmp_partitions_order): Update.
	(lto_wpa_write_files): Update.
	(free_ltrans_partitions): Update.
	(add_references_to_partition): Update.
	(add_cgraph_node_to_partition_1): Update.
	(add_cgraph_node_to_partition): Update.
	(add_varpool_node_to_partition): Update.
	(undo_partition): Update.
	(lto_balanced_map): Update.
	(set_referenced_from_other_partition_p, set_reachable_from_other_partition_p,
	set_referenced_from_this_partition_p): Update.
	(lto_promote_cross_file_statics): Update.

From-SVN: r191107
parent d5f8c6dc
2012-09-08 Jan Hubicka <jh@suse.cz>
Replace cgraph_node_set and varpool_node_set by symtab_node_encoder
in partitioning.
* tree-pass.h (cgraph_node_set_def, varpool_node_set_def): Remove
forward declaration.
(lto_symtab_encoder_d): Forward declare.
(ipa_write_optimization_summaries): Update.
* lto-cgraph.c (lto_symtab_encoder_new): Do not initialize
body, initializer and in_partition.
(lto_symtab_encoder_delete): Update.
(lto_symtab_encoder_encode): Update.
(lto_symtab_encoder_lookup): Move inline.
(lto_symtab_encoder_delete_node): New function.
(lto_symtab_encoder_encode_body_p, lto_set_symtab_encoder_encode_body,
lto_symtab_encoder_encode_initializer_p,
lto_set_symtab_encoder_encode_initializer, lto_symtab_encoder_in_partition_p,
lto_symtab_encoder_in_partition_p): Update.
(compute_ltrans_boundary): Take encoder as an input.
* passes.c (ipa_write_summaries_1): Update.
(ipa_write_summaries_1): Update.
(ipa_write_summaries): Update.
(ipa_write_optimization_summaries): Update.
* lto-streamer.c (print_lto_report): Report number of cgraph nodes.
* lto-streamer.h (lto_stats_d): Replace num_output_cgraph_nodes by
num_output_symtab_nodes.
(lto_encoder_entry): New structure.
(struct lto_symtab_encoder_d): Reorg.
(lto_symtab_encoder_delete_node): Declare.
(lto_symtab_encoder_lookup): Bring inline.
(compute_ltrans_boundary): Update.
(lto_symtab_encoder_size): Update.
(lsei_node, lsei_cgraph_node, lsei_varpool_node): Update.
(lto_symtab_encoder_deref): Update.
2012-09-08 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> 2012-09-08 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* config/pa/pa.c (hppa_rtx_costs): Update costs for large integer modes. * config/pa/pa.c (hppa_rtx_costs): Update costs for large integer modes.
......
...@@ -80,9 +80,6 @@ lto_symtab_encoder_new (void) ...@@ -80,9 +80,6 @@ lto_symtab_encoder_new (void)
lto_symtab_encoder_t encoder = XCNEW (struct lto_symtab_encoder_d); lto_symtab_encoder_t encoder = XCNEW (struct lto_symtab_encoder_d);
encoder->map = pointer_map_create (); encoder->map = pointer_map_create ();
encoder->nodes = NULL; encoder->nodes = NULL;
encoder->body = pointer_set_create ();
encoder->initializer = pointer_set_create ();
encoder->in_partition = pointer_set_create ();
return encoder; return encoder;
} }
...@@ -92,11 +89,8 @@ lto_symtab_encoder_new (void) ...@@ -92,11 +89,8 @@ lto_symtab_encoder_new (void)
void void
lto_symtab_encoder_delete (lto_symtab_encoder_t encoder) lto_symtab_encoder_delete (lto_symtab_encoder_t encoder)
{ {
VEC_free (symtab_node, heap, encoder->nodes); VEC_free (lto_encoder_entry, heap, encoder->nodes);
pointer_map_destroy (encoder->map); pointer_map_destroy (encoder->map);
pointer_set_destroy (encoder->body);
pointer_set_destroy (encoder->initializer);
pointer_set_destroy (encoder->in_partition);
free (encoder); free (encoder);
} }
...@@ -113,29 +107,57 @@ lto_symtab_encoder_encode (lto_symtab_encoder_t encoder, ...@@ -113,29 +107,57 @@ lto_symtab_encoder_encode (lto_symtab_encoder_t encoder,
void **slot; void **slot;
slot = pointer_map_contains (encoder->map, node); slot = pointer_map_contains (encoder->map, node);
if (!slot) if (!slot || !*slot)
{ {
ref = VEC_length (symtab_node, encoder->nodes); lto_encoder_entry entry = {node, false, false, false};
slot = pointer_map_insert (encoder->map, node); ref = VEC_length (lto_encoder_entry, encoder->nodes);
*slot = (void *) (intptr_t) ref; if (!slot)
VEC_safe_push (symtab_node, heap, encoder->nodes, node); slot = pointer_map_insert (encoder->map, node);
*slot = (void *) (intptr_t) (ref + 1);
VEC_safe_push (lto_encoder_entry, heap, encoder->nodes, &entry);
} }
else else
ref = (int) (intptr_t) *slot; ref = (size_t) *slot - 1;
return ref; return ref;
} }
/* Remove NODE from encoder. */
/* Look up NODE in encoder. Return NODE's reference if it has been encoded bool
or LCC_NOT_FOUND if it is not there. */ lto_symtab_encoder_delete_node (lto_symtab_encoder_t encoder,
symtab_node node)
int
lto_symtab_encoder_lookup (lto_symtab_encoder_t encoder,
symtab_node node)
{ {
void **slot = pointer_map_contains (encoder->map, node); void **slot, **last_slot;
return (slot ? (int) (intptr_t) *slot : LCC_NOT_FOUND); int index;
lto_encoder_entry last_node;
slot = pointer_map_contains (encoder->map, node);
if (slot == NULL || !*slot)
return false;
index = (size_t) *slot - 1;
gcc_checking_assert (VEC_index (lto_encoder_entry,
encoder->nodes, index).node
== node);
/* Remove from vector. We do this by swapping node with the last element
of the vector. */
last_node = VEC_pop (lto_encoder_entry, encoder->nodes);
if (last_node.node != node)
{
last_slot = pointer_map_contains (encoder->map, last_node.node);
gcc_checking_assert (last_slot && *last_slot);
*last_slot = (void *)(size_t) (index + 1);
/* Move the last element to the original spot of NODE. */
VEC_replace (lto_encoder_entry, encoder->nodes, index,
last_node);
}
/* Remove element from hash table. */
*slot = NULL;
return true;
} }
...@@ -145,7 +167,8 @@ bool ...@@ -145,7 +167,8 @@ bool
lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t encoder, lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t encoder,
struct cgraph_node *node) struct cgraph_node *node)
{ {
return pointer_set_contains (encoder->body, node); int index = lto_symtab_encoder_lookup (encoder, (symtab_node)node);
return VEC_index (lto_encoder_entry, encoder->nodes, index).body;
} }
/* Return TRUE if we should encode body of NODE (if any). */ /* Return TRUE if we should encode body of NODE (if any). */
...@@ -154,7 +177,10 @@ static void ...@@ -154,7 +177,10 @@ static void
lto_set_symtab_encoder_encode_body (lto_symtab_encoder_t encoder, lto_set_symtab_encoder_encode_body (lto_symtab_encoder_t encoder,
struct cgraph_node *node) struct cgraph_node *node)
{ {
pointer_set_insert (encoder->body, node); int index = lto_symtab_encoder_encode (encoder, (symtab_node)node);
gcc_checking_assert (VEC_index (lto_encoder_entry, encoder->nodes,
index).node == (symtab_node)node);
VEC_index (lto_encoder_entry, encoder->nodes, index).body = true;
} }
/* Return TRUE if we should encode initializer of NODE (if any). */ /* Return TRUE if we should encode initializer of NODE (if any). */
...@@ -163,7 +189,10 @@ bool ...@@ -163,7 +189,10 @@ bool
lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t encoder, lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t encoder,
struct varpool_node *node) struct varpool_node *node)
{ {
return pointer_set_contains (encoder->initializer, node); int index = lto_symtab_encoder_lookup (encoder, (symtab_node)node);
if (index == LCC_NOT_FOUND)
return false;
return VEC_index (lto_encoder_entry, encoder->nodes, index).initializer;
} }
/* Return TRUE if we should encode initializer of NODE (if any). */ /* Return TRUE if we should encode initializer of NODE (if any). */
...@@ -172,7 +201,8 @@ static void ...@@ -172,7 +201,8 @@ static void
lto_set_symtab_encoder_encode_initializer (lto_symtab_encoder_t encoder, lto_set_symtab_encoder_encode_initializer (lto_symtab_encoder_t encoder,
struct varpool_node *node) struct varpool_node *node)
{ {
pointer_set_insert (encoder->initializer, node); int index = lto_symtab_encoder_lookup (encoder, (symtab_node)node);
VEC_index (lto_encoder_entry, encoder->nodes, index).initializer = true;
} }
/* Return TRUE if we should encode initializer of NODE (if any). */ /* Return TRUE if we should encode initializer of NODE (if any). */
...@@ -181,7 +211,10 @@ bool ...@@ -181,7 +211,10 @@ bool
lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder, lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder,
symtab_node node) symtab_node node)
{ {
return pointer_set_contains (encoder->in_partition, node); int index = lto_symtab_encoder_lookup (encoder, (symtab_node)node);
if (index == LCC_NOT_FOUND)
return false;
return VEC_index (lto_encoder_entry, encoder->nodes, index).in_partition;
} }
/* Return TRUE if we should encode body of NODE (if any). */ /* Return TRUE if we should encode body of NODE (if any). */
...@@ -190,8 +223,8 @@ void ...@@ -190,8 +223,8 @@ void
lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder, lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder,
symtab_node node) symtab_node node)
{ {
lto_symtab_encoder_encode (encoder, (symtab_node)node); int index = lto_symtab_encoder_encode (encoder, (symtab_node)node);
pointer_set_insert (encoder->in_partition, node); VEC_index (lto_encoder_entry, encoder->nodes, index).in_partition = true;
} }
/* Output the cgraph EDGE to OB using ENCODER. */ /* Output the cgraph EDGE to OB using ENCODER. */
...@@ -645,28 +678,31 @@ output_refs (lto_symtab_encoder_t encoder) ...@@ -645,28 +678,31 @@ output_refs (lto_symtab_encoder_t encoder)
and insert them to encoders. */ and insert them to encoders. */
void void
compute_ltrans_boundary (struct lto_out_decl_state *state, compute_ltrans_boundary (struct lto_out_decl_state *state,
cgraph_node_set set, varpool_node_set vset) lto_symtab_encoder_t in_encoder)
{ {
struct cgraph_node *node; struct cgraph_node *node;
cgraph_node_set_iterator csi;
varpool_node_set_iterator vsi;
struct cgraph_edge *edge; struct cgraph_edge *edge;
int i; int i;
lto_symtab_encoder_t encoder; lto_symtab_encoder_t encoder;
lto_symtab_encoder_iterator lsei;
encoder = state->symtab_node_encoder = lto_symtab_encoder_new (); encoder = state->symtab_node_encoder = lto_symtab_encoder_new ();
/* Go over all the nodes in SET and assign references. */ /* Go over all entries in the IN_ENCODER and duplicate them to
for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) ENCODER. At the same time insert masters of clones so
every master appears before clone. */
for (lsei = lsei_start_function_in_partition (in_encoder);
!lsei_end_p (lsei); lsei_next_function_in_partition (&lsei))
{ {
node = csi_node (csi); node = lsei_cgraph_node (lsei);
add_node_to (encoder, node, true); add_node_to (encoder, node, true);
lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node); lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node);
add_references (encoder, &node->symbol.ref_list); add_references (encoder, &node->symbol.ref_list);
} }
for (vsi = vsi_start (vset); !vsi_end_p (vsi); vsi_next (&vsi)) for (lsei = lsei_start_variable_in_partition (in_encoder);
!lsei_end_p (lsei); lsei_next_variable_in_partition (&lsei))
{ {
struct varpool_node *vnode = vsi_node (vsi); struct varpool_node *vnode = lsei_varpool_node (lsei);
gcc_assert (!vnode->alias || vnode->alias_of); gcc_assert (!vnode->alias || vnode->alias_of);
lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode); lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode);
lto_set_symtab_encoder_encode_initializer (encoder, vnode); lto_set_symtab_encoder_encode_initializer (encoder, vnode);
...@@ -696,13 +732,14 @@ compute_ltrans_boundary (struct lto_out_decl_state *state, ...@@ -696,13 +732,14 @@ compute_ltrans_boundary (struct lto_out_decl_state *state,
/* Go over all the nodes again to include callees that are not in /* Go over all the nodes again to include callees that are not in
SET. */ SET. */
for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) for (lsei = lsei_start_function_in_partition (encoder);
!lsei_end_p (lsei); lsei_next_function_in_partition (&lsei))
{ {
node = csi_node (csi); node = lsei_cgraph_node (lsei);
for (edge = node->callees; edge; edge = edge->next_callee) for (edge = node->callees; edge; edge = edge->next_callee)
{ {
struct cgraph_node *callee = edge->callee; struct cgraph_node *callee = edge->callee;
if (!cgraph_node_in_set_p (callee, set)) if (!lto_symtab_encoder_in_partition_p (encoder, (symtab_node)callee))
{ {
/* We should have moved all the inlines. */ /* We should have moved all the inlines. */
gcc_assert (!callee->global.inlined_to); gcc_assert (!callee->global.inlined_to);
......
...@@ -228,9 +228,9 @@ print_lto_report (void) ...@@ -228,9 +228,9 @@ print_lto_report (void)
HOST_WIDE_INT_PRINT_UNSIGNED "\n", s, HOST_WIDE_INT_PRINT_UNSIGNED "\n", s,
lto_stats.num_output_files); lto_stats.num_output_files);
fprintf (stderr, "[%s] # of output cgraph nodes: " fprintf (stderr, "[%s] # of output symtab nodes: "
HOST_WIDE_INT_PRINT_UNSIGNED "\n", s, HOST_WIDE_INT_PRINT_UNSIGNED "\n", s,
lto_stats.num_output_cgraph_nodes); lto_stats.num_output_symtab_nodes);
fprintf (stderr, "[%s] # callgraph partitions: " fprintf (stderr, "[%s] # callgraph partitions: "
HOST_WIDE_INT_PRINT_UNSIGNED "\n", s, HOST_WIDE_INT_PRINT_UNSIGNED "\n", s,
......
...@@ -407,7 +407,7 @@ struct lto_asm_header ...@@ -407,7 +407,7 @@ struct lto_asm_header
struct lto_stats_d struct lto_stats_d
{ {
unsigned HOST_WIDE_INT num_input_cgraph_nodes; unsigned HOST_WIDE_INT num_input_cgraph_nodes;
unsigned HOST_WIDE_INT num_output_cgraph_nodes; unsigned HOST_WIDE_INT num_output_symtab_nodes;
unsigned HOST_WIDE_INT num_input_files; unsigned HOST_WIDE_INT num_input_files;
unsigned HOST_WIDE_INT num_output_files; unsigned HOST_WIDE_INT num_output_files;
unsigned HOST_WIDE_INT num_cgraph_partitions; unsigned HOST_WIDE_INT num_cgraph_partitions;
...@@ -420,21 +420,29 @@ struct lto_stats_d ...@@ -420,21 +420,29 @@ struct lto_stats_d
unsigned HOST_WIDE_INT num_uncompressed_il_bytes; unsigned HOST_WIDE_INT num_uncompressed_il_bytes;
}; };
/* Entry of LTO symtab encoder. */
typedef struct
{
symtab_node node;
/* Is the node in this partition (i.e. ltrans of this partition will
be responsible for outputting it)? */
unsigned int in_partition:1;
/* Do we encode body in this partition? */
unsigned int body:1;
/* Do we encode initializer in this partition?
For example the readonly variable initializers are encoded to aid
constant folding even if they are not in the partition. */
unsigned int initializer:1;
} lto_encoder_entry;
DEF_VEC_O(lto_encoder_entry);
DEF_VEC_ALLOC_O(lto_encoder_entry, heap);
/* Encoder data structure used to stream callgraph nodes. */ /* Encoder data structure used to stream callgraph nodes. */
struct lto_symtab_encoder_d struct lto_symtab_encoder_d
{ {
/* Map nodes to reference number. */ VEC(lto_encoder_entry,gc) *nodes;
struct pointer_map_t *map; pointer_map_t *map;
/* Map reference number to node. */
VEC(symtab_node,heap) *nodes;
/* Map of nodes where we want to output body. */
struct pointer_set_t *body;
/* Map of nodes where we want to output initializer. */
struct pointer_set_t *initializer;
/* Map of nodes in this partition. */
struct pointer_set_t *in_partition;
}; };
typedef struct lto_symtab_encoder_d *lto_symtab_encoder_t; typedef struct lto_symtab_encoder_d *lto_symtab_encoder_t;
...@@ -825,10 +833,10 @@ void lto_output_location (struct output_block *, location_t); ...@@ -825,10 +833,10 @@ void lto_output_location (struct output_block *, location_t);
/* In lto-cgraph.c */ /* In lto-cgraph.c */
int lto_symtab_encoder_lookup (lto_symtab_encoder_t, symtab_node);
lto_symtab_encoder_t lto_symtab_encoder_new (void); lto_symtab_encoder_t lto_symtab_encoder_new (void);
int lto_symtab_encoder_encode (lto_symtab_encoder_t, symtab_node); int lto_symtab_encoder_encode (lto_symtab_encoder_t, symtab_node);
void lto_symtab_encoder_delete (lto_symtab_encoder_t); void lto_symtab_encoder_delete (lto_symtab_encoder_t);
bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t, symtab_node);
bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t, bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t,
struct cgraph_node *); struct cgraph_node *);
bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t, bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t,
...@@ -849,7 +857,7 @@ bool referenced_from_this_partition_p (struct ipa_ref_list *, ...@@ -849,7 +857,7 @@ bool referenced_from_this_partition_p (struct ipa_ref_list *,
bool reachable_from_this_partition_p (struct cgraph_node *, bool reachable_from_this_partition_p (struct cgraph_node *,
lto_symtab_encoder_t); lto_symtab_encoder_t);
void compute_ltrans_boundary (struct lto_out_decl_state *state, void compute_ltrans_boundary (struct lto_out_decl_state *state,
cgraph_node_set, varpool_node_set); lto_symtab_encoder_t encoder);
/* In lto-symtab.c. */ /* In lto-symtab.c. */
...@@ -1007,7 +1015,21 @@ emit_label_in_global_context_p (tree label) ...@@ -1007,7 +1015,21 @@ emit_label_in_global_context_p (tree label)
static inline int static inline int
lto_symtab_encoder_size (lto_symtab_encoder_t encoder) lto_symtab_encoder_size (lto_symtab_encoder_t encoder)
{ {
return VEC_length (symtab_node, encoder->nodes); return VEC_length (lto_encoder_entry, encoder->nodes);
}
/* Value used to represent failure of lto_symtab_encoder_lookup. */
#define LCC_NOT_FOUND (-1)
/* Look up NODE in encoder. Return NODE's reference if it has been encoded
or LCC_NOT_FOUND if it is not there. */
static inline int
lto_symtab_encoder_lookup (lto_symtab_encoder_t encoder,
symtab_node node)
{
void **slot = pointer_map_contains (encoder->map, node);
return (slot && *slot ? (size_t) *(slot) - 1 : LCC_NOT_FOUND);
} }
/* Return true if iterator LSE points to nothing. */ /* Return true if iterator LSE points to nothing. */
...@@ -1028,26 +1050,26 @@ lsei_next (lto_symtab_encoder_iterator *lsei) ...@@ -1028,26 +1050,26 @@ lsei_next (lto_symtab_encoder_iterator *lsei)
static inline symtab_node static inline symtab_node
lsei_node (lto_symtab_encoder_iterator lsei) lsei_node (lto_symtab_encoder_iterator lsei)
{ {
return VEC_index (symtab_node, lsei.encoder->nodes, lsei.index); return VEC_index (lto_encoder_entry,
lsei.encoder->nodes, lsei.index).node;
} }
/* Return the node pointed to by LSI. */ /* Return the node pointed to by LSI. */
static inline struct cgraph_node * static inline struct cgraph_node *
lsei_cgraph_node (lto_symtab_encoder_iterator lsei) lsei_cgraph_node (lto_symtab_encoder_iterator lsei)
{ {
return cgraph (VEC_index (symtab_node, lsei.encoder->nodes, lsei.index)); return cgraph (VEC_index (lto_encoder_entry,
lsei.encoder->nodes, lsei.index).node);
} }
/* Return the node pointed to by LSI. */ /* Return the node pointed to by LSI. */
static inline struct varpool_node * static inline struct varpool_node *
lsei_varpool_node (lto_symtab_encoder_iterator lsei) lsei_varpool_node (lto_symtab_encoder_iterator lsei)
{ {
return varpool (VEC_index (symtab_node, lsei.encoder->nodes, lsei.index)); return varpool (VEC_index (lto_encoder_entry,
lsei.encoder->nodes, lsei.index).node);
} }
/* Value used to represent failure of lto_symtab_encoder_lookup. */
#define LCC_NOT_FOUND (-1)
/* Return the cgraph node corresponding to REF using ENCODER. */ /* Return the cgraph node corresponding to REF using ENCODER. */
static inline symtab_node static inline symtab_node
...@@ -1056,7 +1078,7 @@ lto_symtab_encoder_deref (lto_symtab_encoder_t encoder, int ref) ...@@ -1056,7 +1078,7 @@ lto_symtab_encoder_deref (lto_symtab_encoder_t encoder, int ref)
if (ref == LCC_NOT_FOUND) if (ref == LCC_NOT_FOUND)
return NULL; return NULL;
return VEC_index (symtab_node, encoder->nodes, ref); return VEC_index (lto_encoder_entry, encoder->nodes, ref).node;
} }
/* Return an iterator to the first node in LSI. */ /* Return an iterator to the first node in LSI. */
......
2012-08-12 Jan Hubicka <jh@suse.cz> 2012-08-12 Jan Hubicka <jh@suse.cz>
Replace cgraph_node_set and varpool_node_set by symtab_node_encoder
in partitioning.
* lto-partition.h (ltrans_partition_def): Replace cgraph_set and varpool_set
by encoder.
* lto-partition.c (new_partition): Update.
* lto.c (cmp_partitions_order): Update.
(lto_wpa_write_files): Update.
(free_ltrans_partitions): Update.
(add_references_to_partition): Update.
(add_cgraph_node_to_partition_1): Update.
(add_cgraph_node_to_partition): Update.
(add_varpool_node_to_partition): Update.
(undo_partition): Update.
(lto_balanced_map): Update.
(set_referenced_from_other_partition_p, set_reachable_from_other_partition_p,
set_referenced_from_this_partition_p): Update.
(lto_promote_cross_file_statics): Update.
2012-08-12 Jan Hubicka <jh@suse.cz>
* lto-partition.c (set_referenced_from_other_partition_p, * lto-partition.c (set_referenced_from_other_partition_p,
set_reachable_from_other_partition_p, set_referenced_from_this_partition_p): set_reachable_from_other_partition_p, set_referenced_from_this_partition_p):
New functions. New functions.
......
...@@ -22,8 +22,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -22,8 +22,7 @@ along with GCC; see the file COPYING3. If not see
struct ltrans_partition_def struct ltrans_partition_def
{ {
cgraph_node_set cgraph_set; lto_symtab_encoder_t encoder;
varpool_node_set varpool_set;
const char * name; const char * name;
int insns; int insns;
}; };
......
...@@ -1421,14 +1421,10 @@ cmp_partitions_order (const void *a, const void *b) ...@@ -1421,14 +1421,10 @@ cmp_partitions_order (const void *a, const void *b)
= *(struct ltrans_partition_def *const *)b; = *(struct ltrans_partition_def *const *)b;
int ordera = -1, orderb = -1; int ordera = -1, orderb = -1;
if (VEC_length (cgraph_node_ptr, pa->cgraph_set->nodes)) if (lto_symtab_encoder_size (pa->encoder))
ordera = VEC_index (cgraph_node_ptr, pa->cgraph_set->nodes, 0)->symbol.order; ordera = lto_symtab_encoder_deref (pa->encoder, 0)->symbol.order;
else if (VEC_length (varpool_node_ptr, pa->varpool_set->nodes)) if (lto_symtab_encoder_size (pb->encoder))
ordera = VEC_index (varpool_node_ptr, pa->varpool_set->nodes, 0)->symbol.order; orderb = lto_symtab_encoder_deref (pb->encoder, 0)->symbol.order;
if (VEC_length (cgraph_node_ptr, pb->cgraph_set->nodes))
orderb = VEC_index (cgraph_node_ptr, pb->cgraph_set->nodes, 0)->symbol.order;
else if (VEC_length (varpool_node_ptr, pb->varpool_set->nodes))
orderb = VEC_index (varpool_node_ptr, pb->varpool_set->nodes, 0)->symbol.order;
return orderb - ordera; return orderb - ordera;
} }
...@@ -1440,8 +1436,6 @@ lto_wpa_write_files (void) ...@@ -1440,8 +1436,6 @@ lto_wpa_write_files (void)
{ {
unsigned i, n_sets; unsigned i, n_sets;
lto_file *file; lto_file *file;
cgraph_node_set set;
varpool_node_set vset;
ltrans_partition part; ltrans_partition part;
FILE *ltrans_output_list_stream; FILE *ltrans_output_list_stream;
char *temp_filename; char *temp_filename;
...@@ -1457,8 +1451,7 @@ lto_wpa_write_files (void) ...@@ -1457,8 +1451,7 @@ lto_wpa_write_files (void)
timevar_push (TV_WHOPR_WPA); timevar_push (TV_WHOPR_WPA);
FOR_EACH_VEC_ELT (ltrans_partition, ltrans_partitions, i, part) FOR_EACH_VEC_ELT (ltrans_partition, ltrans_partitions, i, part)
lto_stats.num_output_cgraph_nodes += VEC_length (cgraph_node_ptr, lto_stats.num_output_symtab_nodes += lto_symtab_encoder_size (part->encoder);
part->cgraph_set->nodes);
/* Find out statics that need to be promoted /* Find out statics that need to be promoted
to globals with hidden visibility because they are accessed from multiple to globals with hidden visibility because they are accessed from multiple
...@@ -1491,9 +1484,6 @@ lto_wpa_write_files (void) ...@@ -1491,9 +1484,6 @@ lto_wpa_write_files (void)
size_t len; size_t len;
ltrans_partition part = VEC_index (ltrans_partition, ltrans_partitions, i); ltrans_partition part = VEC_index (ltrans_partition, ltrans_partitions, i);
set = part->cgraph_set;
vset = part->varpool_set;
/* Write all the nodes in SET. */ /* Write all the nodes in SET. */
sprintf (temp_filename + blen, "%u.o", i); sprintf (temp_filename + blen, "%u.o", i);
file = lto_obj_file_open (temp_filename, true); file = lto_obj_file_open (temp_filename, true);
...@@ -1504,22 +1494,28 @@ lto_wpa_write_files (void) ...@@ -1504,22 +1494,28 @@ lto_wpa_write_files (void)
fprintf (stderr, " %s (%s %i insns)", temp_filename, part->name, part->insns); fprintf (stderr, " %s (%s %i insns)", temp_filename, part->name, part->insns);
if (cgraph_dump_file) if (cgraph_dump_file)
{ {
lto_symtab_encoder_iterator lsei;
fprintf (cgraph_dump_file, "Writing partition %s to file %s, %i insns\n", fprintf (cgraph_dump_file, "Writing partition %s to file %s, %i insns\n",
part->name, temp_filename, part->insns); part->name, temp_filename, part->insns);
fprintf (cgraph_dump_file, "cgraph nodes:"); for (lsei = lsei_start_in_partition (part->encoder); !lsei_end_p (lsei);
dump_cgraph_node_set (cgraph_dump_file, set); lsei_next_in_partition (&lsei))
fprintf (cgraph_dump_file, "varpool nodes:"); {
dump_varpool_node_set (cgraph_dump_file, vset); symtab_node node = lsei_node (lsei);
fprintf (cgraph_dump_file, "%s ", symtab_node_name (node));
}
fprintf (cgraph_dump_file, "\n");
} }
gcc_checking_assert (cgraph_node_set_nonempty_p (set) gcc_checking_assert (lto_symtab_encoder_size (part->encoder) || !i);
|| varpool_node_set_nonempty_p (vset) || !i);
lto_set_current_out_file (file); lto_set_current_out_file (file);
ipa_write_optimization_summaries (set, vset); ipa_write_optimization_summaries (part->encoder);
lto_set_current_out_file (NULL); lto_set_current_out_file (NULL);
lto_obj_file_close (file); lto_obj_file_close (file);
lto_symtab_encoder_delete (part->encoder);
part->encoder = NULL;
len = strlen (temp_filename); len = strlen (temp_filename);
if (fwrite (temp_filename, 1, len, ltrans_output_list_stream) < len if (fwrite (temp_filename, 1, len, ltrans_output_list_stream) < len
......
...@@ -2261,10 +2261,10 @@ ipa_write_summaries_2 (struct opt_pass *pass, struct lto_out_decl_state *state) ...@@ -2261,10 +2261,10 @@ ipa_write_summaries_2 (struct opt_pass *pass, struct lto_out_decl_state *state)
summaries. SET is the set of nodes to be written. */ summaries. SET is the set of nodes to be written. */
static void static void
ipa_write_summaries_1 (cgraph_node_set set, varpool_node_set vset) ipa_write_summaries_1 (lto_symtab_encoder_t encoder)
{ {
struct lto_out_decl_state *state = lto_new_out_decl_state (); struct lto_out_decl_state *state = lto_new_out_decl_state ();
compute_ltrans_boundary (state, set, vset); compute_ltrans_boundary (state, encoder);
lto_push_out_decl_state (state); lto_push_out_decl_state (state);
...@@ -2282,16 +2282,15 @@ ipa_write_summaries_1 (cgraph_node_set set, varpool_node_set vset) ...@@ -2282,16 +2282,15 @@ ipa_write_summaries_1 (cgraph_node_set set, varpool_node_set vset)
void void
ipa_write_summaries (void) ipa_write_summaries (void)
{ {
cgraph_node_set set; lto_symtab_encoder_t encoder;
varpool_node_set vset;
struct cgraph_node **order;
struct varpool_node *vnode;
int i, order_pos; int i, order_pos;
struct varpool_node *vnode;
struct cgraph_node **order;
if (!flag_generate_lto || seen_error ()) if (!flag_generate_lto || seen_error ())
return; return;
set = cgraph_node_set_new (); encoder = lto_symtab_encoder_new ();
/* Create the callgraph set in the same order used in /* Create the callgraph set in the same order used in
cgraph_expand_all_functions. This mostly facilitates debugging, cgraph_expand_all_functions. This mostly facilitates debugging,
...@@ -2318,19 +2317,16 @@ ipa_write_summaries (void) ...@@ -2318,19 +2317,16 @@ ipa_write_summaries (void)
pop_cfun (); pop_cfun ();
} }
if (node->analyzed) if (node->analyzed)
cgraph_node_set_add (set, node); lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node);
} }
vset = varpool_node_set_new ();
FOR_EACH_DEFINED_VARIABLE (vnode) FOR_EACH_DEFINED_VARIABLE (vnode)
if ((!vnode->alias || vnode->alias_of)) if ((!vnode->alias || vnode->alias_of))
varpool_node_set_add (vset, vnode); lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode);
ipa_write_summaries_1 (set, vset); ipa_write_summaries_1 (encoder);
free (order); free (order);
free_cgraph_node_set (set);
free_varpool_node_set (vset);
} }
/* Same as execute_pass_list but assume that subpasses of IPA passes /* Same as execute_pass_list but assume that subpasses of IPA passes
...@@ -2376,16 +2372,17 @@ ipa_write_optimization_summaries_1 (struct opt_pass *pass, struct lto_out_decl_s ...@@ -2376,16 +2372,17 @@ ipa_write_optimization_summaries_1 (struct opt_pass *pass, struct lto_out_decl_s
NULL, write out all summaries of all nodes. */ NULL, write out all summaries of all nodes. */
void void
ipa_write_optimization_summaries (cgraph_node_set set, varpool_node_set vset) ipa_write_optimization_summaries (lto_symtab_encoder_t encoder)
{ {
struct lto_out_decl_state *state = lto_new_out_decl_state (); struct lto_out_decl_state *state = lto_new_out_decl_state ();
cgraph_node_set_iterator csi; lto_symtab_encoder_iterator lsei;
compute_ltrans_boundary (state, set, vset); compute_ltrans_boundary (state, encoder);
lto_push_out_decl_state (state); lto_push_out_decl_state (state);
for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) for (lsei = lsei_start_function_in_partition (encoder);
!lsei_end_p (lsei); lsei_next_function_in_partition (&lsei))
{ {
struct cgraph_node *node = csi_node (csi); struct cgraph_node *node = lsei_cgraph_node (lsei);
/* When streaming out references to statements as part of some IPA /* When streaming out references to statements as part of some IPA
pass summary, the statements need to have uids assigned. pass summary, the statements need to have uids assigned.
......
...@@ -92,8 +92,7 @@ struct rtl_opt_pass ...@@ -92,8 +92,7 @@ struct rtl_opt_pass
struct varpool_node; struct varpool_node;
struct cgraph_node; struct cgraph_node;
struct cgraph_node_set_def; struct lto_symtab_encoder_d;
struct varpool_node_set_def;
/* Description of IPA pass with generate summary, write, execute, read and /* Description of IPA pass with generate summary, write, execute, read and
transform stages. */ transform stages. */
...@@ -526,8 +525,7 @@ extern const char *get_current_pass_name (void); ...@@ -526,8 +525,7 @@ extern const char *get_current_pass_name (void);
extern void print_current_pass (FILE *); extern void print_current_pass (FILE *);
extern void debug_pass (void); extern void debug_pass (void);
extern void ipa_write_summaries (void); extern void ipa_write_summaries (void);
extern void ipa_write_optimization_summaries (struct cgraph_node_set_def *, extern void ipa_write_optimization_summaries (struct lto_symtab_encoder_d *);
struct varpool_node_set_def *);
extern void ipa_read_summaries (void); extern void ipa_read_summaries (void);
extern void ipa_read_optimization_summaries (void); extern void ipa_read_optimization_summaries (void);
extern void register_one_dump_file (struct opt_pass *); extern void register_one_dump_file (struct opt_pass *);
......
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