Commit f27c1867 by Jan Hubicka Committed by Jan Hubicka

tree-pass.h (write_summary, [...]): Remove set and vset arguments.


	* tree-pass.h (write_summary, write_optimization_summary): Remove
	set and vset arguments.
	* ipa-cp.c (ipcp_write_summary): Remove set and vset arugments.
	(write_node_summary_p): Likewise; use the encoder.
	(ipa_reference_write_optimization_summary): Likewise.
	* lto-cgraph.c (output_cgraph_opt_summary): Use encoder.
	(lto_symtab_encoder_new): Initialize in_partition field.
	(lto_symtab_encoder_delete): Destroy in_partition field.
	(LCC_NOT_FOUND): Move to lto-streamer.h
	(lto_symtab_encoder_deref): Likewise.
	(lto_symtab_encoder_in_partition_p,
	lto_set_symtab_encoder_in_partition): New functions.
	(referenced_from_other_partition_p): Rewrite to use encoder.
	(reachable_from_other_partition_p): Likewise.
	(referenced_from_this_partition_p): Likewise.
	(reachable_from_this_partition_p): Likewise.
	(lto_output_node): Likewise.
	(lto_output_varpool_node): Likewise.
	(output_refs): Likewise.
	(compute_ltrans_boundary): Initialize in_partition fileds of
	the encoder.
	(output_symtab): Likewise.
	(input_refs): Match the changes in output_refs.
	(output_cgraph_opt_summary_p): Remove set argument.
	(output_node_opt_summary): Replace set by encoder.
	(output_cgraph_opt_summary): Remove set argument; use
	the encoder.
	* ipa-pure-const.c (pure_const_write_summary): Remove set and vset
	arguments; use the encoder.
	* lto-streamer-out.c (lto_output): Remove set and vset argument; use
	the encoder.
	(produce_symtab): Likewise.
	* ipa-inline.h (inline_write_summary): Remove set and vset arguments.
	* ipa-inline-analysis.c (inline_write_summary): Likewise.
	* ipa-prop.c (ipa_prop_write_jump_functions): Remove set argument;
	use encoder.
	* ipa-prop.h (ipa_prop_write_jump_functions): Likewise.
	* passes.c (ipa_write_summaries_2): Remove set and vset arguments.
	(ipa_write_summaries_1): Update.
	(ipa_write_optimization_summaries_1): Likewise.
	(ipa_write_optimization_summaries): Likewise.
	* lto-streamer.h (lto_symtab_encoder_t): Add in_partition.
	(lto_symtab_encoder_iterator): New type.
	(lto_symtab_encoder_deref): Make inline.
	(output_symtab, referenced_from_other_partition_p,
	reachable_from_other_partition_p, referenced_from_this_partition_p,
	reachable_from_this_partition_p): Update.
	(lsei_end_p, lsei_next, lsei_node, lsei_cgraph_node, lsei_varpool_node): New
	inline functions.
	(LCC_NOT_FOUND): New macro.
	(lto_symtab_encoder_deref, lsei_start, lsei_next_in_partition,
	lsei_start_in_partition, lsei_next_function_in_partition,
	lsei_start_function_in_partition, lsei_next_variable_in_partition,
	lsei_start_variable_in_partition): New inline functions.

	* lto-partition.c (set_referenced_from_other_partition_p,
	set_reachable_from_other_partition_p, set_referenced_from_this_partition_p):
	New functions.
	(lto_promote_cross_file_statics): Use them.

From-SVN: r190336
parent 56142d02
2012-08-12 Jan Hubicka <jh@suse.cz>
* tree-pass.h (write_summary, write_optimization_summary): Remove
set and vset arguments.
* ipa-cp.c (ipcp_write_summary): Remove set and vset arugments.
(write_node_summary_p): Likewise; use the encoder.
(ipa_reference_write_optimization_summary): Likewise.
* lto-cgraph.c (output_cgraph_opt_summary): Use encoder.
(lto_symtab_encoder_new): Initialize in_partition field.
(lto_symtab_encoder_delete): Destroy in_partition field.
(LCC_NOT_FOUND): Move to lto-streamer.h
(lto_symtab_encoder_deref): Likewise.
(lto_symtab_encoder_in_partition_p,
lto_set_symtab_encoder_in_partition): New functions.
(referenced_from_other_partition_p): Rewrite to use encoder.
(reachable_from_other_partition_p): Likewise.
(referenced_from_this_partition_p): Likewise.
(reachable_from_this_partition_p): Likewise.
(lto_output_node): Likewise.
(lto_output_varpool_node): Likewise.
(output_refs): Likewise.
(compute_ltrans_boundary): Initialize in_partition fileds of
the encoder.
(output_symtab): Likewise.
(input_refs): Match the changes in output_refs.
(output_cgraph_opt_summary_p): Remove set argument.
(output_node_opt_summary): Replace set by encoder.
(output_cgraph_opt_summary): Remove set argument; use
the encoder.
* ipa-pure-const.c (pure_const_write_summary): Remove set and vset
arguments; use the encoder.
* lto-streamer-out.c (lto_output): Remove set and vset argument; use
the encoder.
(produce_symtab): Likewise.
* ipa-inline.h (inline_write_summary): Remove set and vset arguments.
* ipa-inline-analysis.c (inline_write_summary): Likewise.
* ipa-prop.c (ipa_prop_write_jump_functions): Remove set argument;
use encoder.
* ipa-prop.h (ipa_prop_write_jump_functions): Likewise.
* passes.c (ipa_write_summaries_2): Remove set and vset arguments.
(ipa_write_summaries_1): Update.
(ipa_write_optimization_summaries_1): Likewise.
(ipa_write_optimization_summaries): Likewise.
* lto-streamer.h (lto_symtab_encoder_t): Add in_partition.
(lto_symtab_encoder_iterator): New type.
(lto_symtab_encoder_deref): Make inline.
(output_symtab, referenced_from_other_partition_p,
reachable_from_other_partition_p, referenced_from_this_partition_p,
reachable_from_this_partition_p): Update.
(lsei_end_p, lsei_next, lsei_node, lsei_cgraph_node, lsei_varpool_node): New
inline functions.
(LCC_NOT_FOUND): New macro.
(lto_symtab_encoder_deref, lsei_start, lsei_next_in_partition,
lsei_start_in_partition, lsei_next_function_in_partition,
lsei_start_function_in_partition, lsei_next_variable_in_partition,
lsei_start_variable_in_partition): New inline functions.
2012-08-12 Oleg Endo <olegendo@gcc.gnu.org> 2012-08-12 Oleg Endo <olegendo@gcc.gnu.org>
* config/sh/sh.md (prefetch): Simplify expander. Fix condition to * config/sh/sh.md (prefetch): Simplify expander. Fix condition to
......
...@@ -2508,10 +2508,9 @@ ipcp_generate_summary (void) ...@@ -2508,10 +2508,9 @@ ipcp_generate_summary (void)
/* Write ipcp summary for nodes in SET. */ /* Write ipcp summary for nodes in SET. */
static void static void
ipcp_write_summary (cgraph_node_set set, ipcp_write_summary (void)
varpool_node_set vset ATTRIBUTE_UNUSED)
{ {
ipa_prop_write_jump_functions (set); ipa_prop_write_jump_functions ();
} }
/* Read ipcp summary. */ /* Read ipcp summary. */
......
...@@ -3358,8 +3358,7 @@ write_inline_edge_summary (struct output_block *ob, struct cgraph_edge *e) ...@@ -3358,8 +3358,7 @@ write_inline_edge_summary (struct output_block *ob, struct cgraph_edge *e)
active, we don't need to write them twice. */ active, we don't need to write them twice. */
void void
inline_write_summary (cgraph_node_set set, inline_write_summary (void)
varpool_node_set vset ATTRIBUTE_UNUSED)
{ {
struct cgraph_node *node; struct cgraph_node *node;
symtab_node snode; symtab_node snode;
...@@ -3426,7 +3425,7 @@ inline_write_summary (cgraph_node_set set, ...@@ -3426,7 +3425,7 @@ inline_write_summary (cgraph_node_set set,
destroy_output_block (ob); destroy_output_block (ob);
if (optimize && !flag_ipa_cp) if (optimize && !flag_ipa_cp)
ipa_prop_write_jump_functions (set); ipa_prop_write_jump_functions ();
} }
......
...@@ -171,7 +171,7 @@ void dump_inline_summaries (FILE *f); ...@@ -171,7 +171,7 @@ void dump_inline_summaries (FILE *f);
void dump_inline_summary (FILE * f, struct cgraph_node *node); void dump_inline_summary (FILE * f, struct cgraph_node *node);
void inline_generate_summary (void); void inline_generate_summary (void);
void inline_read_summary (void); void inline_read_summary (void);
void inline_write_summary (cgraph_node_set, varpool_node_set); void inline_write_summary (void);
void inline_free_summary (void); void inline_free_summary (void);
void initialize_inline_failed (struct cgraph_edge *); void initialize_inline_failed (struct cgraph_edge *);
int estimate_time_after_inlining (struct cgraph_node *, struct cgraph_edge *); int estimate_time_after_inlining (struct cgraph_node *, struct cgraph_edge *);
......
...@@ -3391,21 +3391,25 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node, ...@@ -3391,21 +3391,25 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
/* Write jump functions for nodes in SET. */ /* Write jump functions for nodes in SET. */
void void
ipa_prop_write_jump_functions (cgraph_node_set set) ipa_prop_write_jump_functions (void)
{ {
struct cgraph_node *node; struct cgraph_node *node;
struct output_block *ob; struct output_block *ob;
unsigned int count = 0; unsigned int count = 0;
cgraph_node_set_iterator csi; lto_symtab_encoder_iterator lsei;
lto_symtab_encoder_t encoder;
if (!ipa_node_params_vector) if (!ipa_node_params_vector)
return; return;
ob = create_output_block (LTO_section_jump_functions); ob = create_output_block (LTO_section_jump_functions);
encoder = ob->decl_state->symtab_node_encoder;
ob->cgraph_node = NULL; ob->cgraph_node = NULL;
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);
if (cgraph_function_with_gimple_body_p (node) if (cgraph_function_with_gimple_body_p (node)
&& IPA_NODE_REF (node) != NULL) && IPA_NODE_REF (node) != NULL)
count++; count++;
...@@ -3414,9 +3418,10 @@ ipa_prop_write_jump_functions (cgraph_node_set set) ...@@ -3414,9 +3418,10 @@ ipa_prop_write_jump_functions (cgraph_node_set set)
streamer_write_uhwi (ob, count); streamer_write_uhwi (ob, count);
/* Process all of the functions. */ /* Process all of the functions. */
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);
if (cgraph_function_with_gimple_body_p (node) if (cgraph_function_with_gimple_body_p (node)
&& IPA_NODE_REF (node) != NULL) && IPA_NODE_REF (node) != NULL)
ipa_write_node_info (ob, node); ipa_write_node_info (ob, node);
......
...@@ -590,7 +590,7 @@ ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec, ...@@ -590,7 +590,7 @@ ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec,
ipa_parm_adjustment_vec); ipa_parm_adjustment_vec);
void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree); void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
void ipa_prop_write_jump_functions (cgraph_node_set set); void ipa_prop_write_jump_functions (void);
void ipa_prop_read_jump_functions (void); void ipa_prop_read_jump_functions (void);
void ipa_update_after_lto_read (void); void ipa_update_after_lto_read (void);
int ipa_get_param_decl_index (struct ipa_node_params *, tree); int ipa_get_param_decl_index (struct ipa_node_params *, tree);
......
...@@ -935,18 +935,21 @@ generate_summary (void) ...@@ -935,18 +935,21 @@ generate_summary (void)
/* Serialize the ipa info for lto. */ /* Serialize the ipa info for lto. */
static void static void
pure_const_write_summary (cgraph_node_set set, pure_const_write_summary (void)
varpool_node_set vset ATTRIBUTE_UNUSED)
{ {
struct cgraph_node *node; struct cgraph_node *node;
struct lto_simple_output_block *ob struct lto_simple_output_block *ob
= lto_create_simple_output_block (LTO_section_ipa_pure_const); = lto_create_simple_output_block (LTO_section_ipa_pure_const);
unsigned int count = 0; unsigned int count = 0;
cgraph_node_set_iterator csi; lto_symtab_encoder_iterator lsei;
lto_symtab_encoder_t encoder;
for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) encoder = lto_get_out_decl_state ()->symtab_node_encoder;
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);
if (node->analyzed && has_function_state (node)) if (node->analyzed && has_function_state (node))
count++; count++;
} }
...@@ -954,9 +957,10 @@ pure_const_write_summary (cgraph_node_set set, ...@@ -954,9 +957,10 @@ pure_const_write_summary (cgraph_node_set set,
streamer_write_uhwi_stream (ob->main_stream, count); streamer_write_uhwi_stream (ob->main_stream, count);
/* Process all of the functions. */ /* Process all of the functions. */
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);
if (node->analyzed && has_function_state (node)) if (node->analyzed && has_function_state (node))
{ {
struct bitpack_d bp; struct bitpack_d bp;
......
...@@ -956,8 +956,7 @@ propagate (void) ...@@ -956,8 +956,7 @@ propagate (void)
static bool static bool
write_node_summary_p (struct cgraph_node *node, write_node_summary_p (struct cgraph_node *node,
cgraph_node_set set, lto_symtab_encoder_t encoder,
varpool_node_set vset,
bitmap ltrans_statics) bitmap ltrans_statics)
{ {
ipa_reference_optimization_summary_t info; ipa_reference_optimization_summary_t info;
...@@ -976,8 +975,8 @@ write_node_summary_p (struct cgraph_node *node, ...@@ -976,8 +975,8 @@ write_node_summary_p (struct cgraph_node *node,
In future we might also want to include summaries of functions references In future we might also want to include summaries of functions references
by initializers of constant variables references in current unit. */ by initializers of constant variables references in current unit. */
if (!reachable_from_this_partition_p (node, set) if (!reachable_from_this_partition_p (node, encoder)
&& !referenced_from_this_partition_p (&node->symbol.ref_list, set, vset)) && !referenced_from_this_partition_p (&node->symbol.ref_list, encoder))
return false; return false;
/* See if the info has non-empty intersections with vars we want to encode. */ /* See if the info has non-empty intersections with vars we want to encode. */
...@@ -1025,8 +1024,7 @@ stream_out_bitmap (struct lto_simple_output_block *ob, ...@@ -1025,8 +1024,7 @@ stream_out_bitmap (struct lto_simple_output_block *ob,
/* Serialize the ipa info for lto. */ /* Serialize the ipa info for lto. */
static void static void
ipa_reference_write_optimization_summary (cgraph_node_set set, ipa_reference_write_optimization_summary (void)
varpool_node_set vset)
{ {
struct cgraph_node *node; struct cgraph_node *node;
symtab_node snode; symtab_node snode;
...@@ -1049,7 +1047,7 @@ ipa_reference_write_optimization_summary (cgraph_node_set set, ...@@ -1049,7 +1047,7 @@ ipa_reference_write_optimization_summary (cgraph_node_set set,
continue; continue;
vnode = varpool (snode); vnode = varpool (snode);
if (bitmap_bit_p (all_module_statics, DECL_UID (vnode->symbol.decl)) if (bitmap_bit_p (all_module_statics, DECL_UID (vnode->symbol.decl))
&& referenced_from_this_partition_p (&vnode->symbol.ref_list, set, vset)) && referenced_from_this_partition_p (&vnode->symbol.ref_list, encoder))
{ {
tree decl = vnode->symbol.decl; tree decl = vnode->symbol.decl;
bitmap_set_bit (ltrans_statics, DECL_UID (decl)); bitmap_set_bit (ltrans_statics, DECL_UID (decl));
...@@ -1064,7 +1062,7 @@ ipa_reference_write_optimization_summary (cgraph_node_set set, ...@@ -1064,7 +1062,7 @@ ipa_reference_write_optimization_summary (cgraph_node_set set,
for (i = 0; i < lto_symtab_encoder_size (encoder); i++) for (i = 0; i < lto_symtab_encoder_size (encoder); i++)
if (symtab_function_p (snode = lto_symtab_encoder_deref (encoder, i)) if (symtab_function_p (snode = lto_symtab_encoder_deref (encoder, i))
&& write_node_summary_p (cgraph (snode), && write_node_summary_p (cgraph (snode),
set, vset, ltrans_statics)) encoder, ltrans_statics))
count++; count++;
streamer_write_uhwi_stream (ob->main_stream, count); streamer_write_uhwi_stream (ob->main_stream, count);
...@@ -1080,7 +1078,7 @@ ipa_reference_write_optimization_summary (cgraph_node_set set, ...@@ -1080,7 +1078,7 @@ ipa_reference_write_optimization_summary (cgraph_node_set set,
if (!symtab_function_p (snode)) if (!symtab_function_p (snode))
continue; continue;
node = cgraph (snode); node = cgraph (snode);
if (write_node_summary_p (node, set, vset, ltrans_statics)) if (write_node_summary_p (node, encoder, ltrans_statics))
{ {
ipa_reference_optimization_summary_t info; ipa_reference_optimization_summary_t info;
int node_ref; int node_ref;
......
...@@ -973,7 +973,7 @@ copy_function (struct cgraph_node *node) ...@@ -973,7 +973,7 @@ copy_function (struct cgraph_node *node)
/* Main entry point from the pass manager. */ /* Main entry point from the pass manager. */
static void static void
lto_output (cgraph_node_set set, varpool_node_set vset) lto_output (void)
{ {
struct cgraph_node *node; struct cgraph_node *node;
struct lto_out_decl_state *decl_state; struct lto_out_decl_state *decl_state;
...@@ -1018,7 +1018,7 @@ lto_output (cgraph_node_set set, varpool_node_set vset) ...@@ -1018,7 +1018,7 @@ lto_output (cgraph_node_set set, varpool_node_set vset)
be done now to make sure that all the statements in every function be done now to make sure that all the statements in every function
have been renumbered so that edges can be associated with call have been renumbered so that edges can be associated with call
statements using the statement UIDs. */ statements using the statement UIDs. */
output_symtab (set, vset); output_symtab ();
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
lto_bitmap_free (output); lto_bitmap_free (output);
...@@ -1388,8 +1388,7 @@ produce_symtab (struct output_block *ob) ...@@ -1388,8 +1388,7 @@ produce_symtab (struct output_block *ob)
recover these on other side. */ recover these on other side. */
static void static void
produce_asm_for_decls (cgraph_node_set set ATTRIBUTE_UNUSED, produce_asm_for_decls (void)
varpool_node_set vset ATTRIBUTE_UNUSED)
{ {
struct lto_out_decl_state *out_state; struct lto_out_decl_state *out_state;
struct lto_out_decl_state *fn_out_state; struct lto_out_decl_state *fn_out_state;
......
...@@ -433,17 +433,21 @@ struct lto_symtab_encoder_d ...@@ -433,17 +433,21 @@ struct lto_symtab_encoder_d
struct pointer_set_t *body; struct pointer_set_t *body;
/* Map of nodes where we want to output initializer. */ /* Map of nodes where we want to output initializer. */
struct pointer_set_t *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;
/* Return number of encoded nodes in ENCODER. */ /* Iterator structure for cgraph node sets. */
typedef struct
static inline int
lto_symtab_encoder_size (lto_symtab_encoder_t encoder)
{ {
return VEC_length (symtab_node, encoder->nodes); lto_symtab_encoder_t encoder;
} unsigned index;
} lto_symtab_encoder_iterator;
/* Mapping from indices to trees. */ /* Mapping from indices to trees. */
struct GTY(()) lto_tree_ref_table struct GTY(()) lto_tree_ref_table
...@@ -808,28 +812,29 @@ void lto_output_location (struct output_block *, location_t); ...@@ -808,28 +812,29 @@ void lto_output_location (struct output_block *, location_t);
/* In lto-cgraph.c */ /* In lto-cgraph.c */
symtab_node lto_symtab_encoder_deref (lto_symtab_encoder_t, int);
int lto_symtab_encoder_lookup (lto_symtab_encoder_t, symtab_node); 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_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,
symtab_node);
void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t,
symtab_node);
bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t, bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t,
struct varpool_node *); struct varpool_node *);
void output_symtab (cgraph_node_set, varpool_node_set); void output_symtab (void);
void input_symtab (void); void input_symtab (void);
bool referenced_from_other_partition_p (struct ipa_ref_list *, bool referenced_from_other_partition_p (struct ipa_ref_list *,
cgraph_node_set, lto_symtab_encoder_t);
varpool_node_set vset);
bool reachable_from_other_partition_p (struct cgraph_node *, bool reachable_from_other_partition_p (struct cgraph_node *,
cgraph_node_set); lto_symtab_encoder_t);
bool referenced_from_this_partition_p (struct ipa_ref_list *, bool referenced_from_this_partition_p (struct ipa_ref_list *,
cgraph_node_set, lto_symtab_encoder_t);
varpool_node_set vset);
bool reachable_from_this_partition_p (struct cgraph_node *, bool reachable_from_this_partition_p (struct cgraph_node *,
cgraph_node_set); 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); cgraph_node_set, varpool_node_set);
...@@ -985,6 +990,149 @@ emit_label_in_global_context_p (tree label) ...@@ -985,6 +990,149 @@ emit_label_in_global_context_p (tree label)
return DECL_NONLOCAL (label) || FORCED_LABEL (label); return DECL_NONLOCAL (label) || FORCED_LABEL (label);
} }
/* Return number of encoded nodes in ENCODER. */
static inline int
lto_symtab_encoder_size (lto_symtab_encoder_t encoder)
{
return VEC_length (symtab_node, encoder->nodes);
}
/* Return true if iterator LSE points to nothing. */
static inline bool
lsei_end_p (lto_symtab_encoder_iterator lsei)
{
return lsei.index >= (unsigned)lto_symtab_encoder_size (lsei.encoder);
}
/* Advance iterator LSE. */
static inline void
lsei_next (lto_symtab_encoder_iterator *lsei)
{
lsei->index++;
}
/* Return the node pointed to by LSI. */
static inline symtab_node
lsei_node (lto_symtab_encoder_iterator lsei)
{
return VEC_index (symtab_node, lsei.encoder->nodes, lsei.index);
}
/* Return the node pointed to by LSI. */
static inline struct cgraph_node *
lsei_cgraph_node (lto_symtab_encoder_iterator lsei)
{
return cgraph (VEC_index (symtab_node, lsei.encoder->nodes, lsei.index));
}
/* Return the node pointed to by LSI. */
static inline struct varpool_node *
lsei_varpool_node (lto_symtab_encoder_iterator lsei)
{
return varpool (VEC_index (symtab_node, lsei.encoder->nodes, lsei.index));
}
/* Value used to represent failure of lto_symtab_encoder_lookup. */
#define LCC_NOT_FOUND (-1)
/* Return the cgraph node corresponding to REF using ENCODER. */
static inline symtab_node
lto_symtab_encoder_deref (lto_symtab_encoder_t encoder, int ref)
{
if (ref == LCC_NOT_FOUND)
return NULL;
return VEC_index (symtab_node, encoder->nodes, ref);
}
/* Return an iterator to the first node in LSI. */
static inline lto_symtab_encoder_iterator
lsei_start (lto_symtab_encoder_t encoder)
{
lto_symtab_encoder_iterator lsei;
lsei.encoder = encoder;
lsei.index = 0;
return lsei;
}
/* Advance iterator LSE. */
static inline void
lsei_next_in_partition (lto_symtab_encoder_iterator *lsei)
{
lsei_next (lsei);
while (!lsei_end_p (*lsei)
&& !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei)))
lsei_next (lsei);
}
/* Return an iterator to the first node in LSI. */
static inline lto_symtab_encoder_iterator
lsei_start_in_partition (lto_symtab_encoder_t encoder)
{
lto_symtab_encoder_iterator lsei = lsei_start (encoder);
if (lsei_end_p (lsei))
return lsei;
if (!lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
lsei_next_in_partition (&lsei);
return lsei;
}
/* Advance iterator LSE. */
static inline void
lsei_next_function_in_partition (lto_symtab_encoder_iterator *lsei)
{
lsei_next (lsei);
while (!lsei_end_p (*lsei)
&& (!symtab_function_p (lsei_node (*lsei))
|| !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei))))
lsei_next (lsei);
}
/* Return an iterator to the first node in LSI. */
static inline lto_symtab_encoder_iterator
lsei_start_function_in_partition (lto_symtab_encoder_t encoder)
{
lto_symtab_encoder_iterator lsei = lsei_start (encoder);
if (lsei_end_p (lsei))
return lsei;
if (!symtab_function_p (lsei_node (lsei))
|| !lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
lsei_next_function_in_partition (&lsei);
return lsei;
}
/* Advance iterator LSE. */
static inline void
lsei_next_variable_in_partition (lto_symtab_encoder_iterator *lsei)
{
lsei_next (lsei);
while (!lsei_end_p (*lsei)
&& (!symtab_variable_p (lsei_node (*lsei))
|| !lto_symtab_encoder_in_partition_p (lsei->encoder, lsei_node (*lsei))))
lsei_next (lsei);
}
/* Return an iterator to the first node in LSI. */
static inline lto_symtab_encoder_iterator
lsei_start_variable_in_partition (lto_symtab_encoder_t encoder)
{
lto_symtab_encoder_iterator lsei = lsei_start (encoder);
if (lsei_end_p (lsei))
return lsei;
if (!symtab_variable_p (lsei_node (lsei))
|| !lto_symtab_encoder_in_partition_p (encoder, lsei_node (lsei)))
lsei_next_variable_in_partition (&lsei);
return lsei;
}
DEFINE_DECL_STREAM_FUNCS (TYPE, type) DEFINE_DECL_STREAM_FUNCS (TYPE, type)
DEFINE_DECL_STREAM_FUNCS (FIELD_DECL, field_decl) DEFINE_DECL_STREAM_FUNCS (FIELD_DECL, field_decl)
DEFINE_DECL_STREAM_FUNCS (FN_DECL, fn_decl) DEFINE_DECL_STREAM_FUNCS (FN_DECL, fn_decl)
......
2012-08-12 Jan Hubicka <jh@suse.cz>
* lto-partition.c (set_referenced_from_other_partition_p,
set_reachable_from_other_partition_p, set_referenced_from_this_partition_p):
New functions.
(lto_promote_cross_file_statics): Use them.
2012-07-24 Jan Hubicka <jh@suse.cz> 2012-07-24 Jan Hubicka <jh@suse.cz>
* lto.c (read_cgraph_and_symbols): Use input_symtab. * lto.c (read_cgraph_and_symbols): Use input_symtab.
......
...@@ -797,6 +797,79 @@ promote_fn (struct cgraph_node *node) ...@@ -797,6 +797,79 @@ promote_fn (struct cgraph_node *node)
return true; return true;
} }
/* Return if LIST contain references from other partitions.
TODO: remove this once lto partitioning is using encoders. */
static bool
set_referenced_from_other_partition_p (struct ipa_ref_list *list, cgraph_node_set set,
varpool_node_set vset)
{
int i;
struct ipa_ref *ref;
for (i = 0; ipa_ref_list_referring_iterate (list, i, ref); i++)
{
if (symtab_function_p (ref->referring))
{
if (ipa_ref_referring_node (ref)->symbol.in_other_partition
|| !cgraph_node_in_set_p (ipa_ref_referring_node (ref), set))
return true;
}
else
{
if (ipa_ref_referring_varpool_node (ref)->symbol.in_other_partition
|| !varpool_node_in_set_p (ipa_ref_referring_varpool_node (ref),
vset))
return true;
}
}
return false;
}
/* Return true when node is reachable from other partition.
TODO: remove this once lto partitioning is using encoders. */
static bool
set_reachable_from_other_partition_p (struct cgraph_node *node, cgraph_node_set set)
{
struct cgraph_edge *e;
if (!node->analyzed)
return false;
if (node->global.inlined_to)
return false;
for (e = node->callers; e; e = e->next_caller)
if (e->caller->symbol.in_other_partition
|| !cgraph_node_in_set_p (e->caller, set))
return true;
return false;
}
/* Return if LIST contain references from other partitions.
TODO: remove this once lto partitioning is using encoders. */
static bool
set_referenced_from_this_partition_p (struct ipa_ref_list *list, cgraph_node_set set,
varpool_node_set vset)
{
int i;
struct ipa_ref *ref;
for (i = 0; ipa_ref_list_referring_iterate (list, i, ref); i++)
{
if (symtab_function_p (ref->referring))
{
if (cgraph_node_in_set_p (ipa_ref_referring_node (ref), set))
return true;
}
else
{
if (varpool_node_in_set_p (ipa_ref_referring_varpool_node (ref),
vset))
return true;
}
}
return false;
}
/* Find out all static decls that need to be promoted to global because /* Find out all static decls that need to be promoted to global because
of cross file sharing. This function must be run in the WPA mode after of cross file sharing. This function must be run in the WPA mode after
all inlinees are added. */ all inlinees are added. */
...@@ -834,8 +907,8 @@ lto_promote_cross_file_statics (void) ...@@ -834,8 +907,8 @@ lto_promote_cross_file_statics (void)
continue; continue;
if ((!DECL_EXTERNAL (node->symbol.decl) if ((!DECL_EXTERNAL (node->symbol.decl)
&& !DECL_COMDAT (node->symbol.decl)) && !DECL_COMDAT (node->symbol.decl))
&& (referenced_from_other_partition_p (&node->symbol.ref_list, set, vset) && (set_referenced_from_other_partition_p (&node->symbol.ref_list, set, vset)
|| reachable_from_other_partition_p (node, set))) || set_reachable_from_other_partition_p (node, set)))
promote_fn (node); promote_fn (node);
} }
for (vsi = vsi_start (vset); !vsi_end_p (vsi); vsi_next (&vsi)) for (vsi = vsi_start (vset); !vsi_end_p (vsi); vsi_next (&vsi))
...@@ -848,7 +921,7 @@ lto_promote_cross_file_statics (void) ...@@ -848,7 +921,7 @@ lto_promote_cross_file_statics (void)
&& !DECL_EXTERNAL (vnode->symbol.decl) && !DECL_EXTERNAL (vnode->symbol.decl)
&& !DECL_COMDAT (vnode->symbol.decl) && !DECL_COMDAT (vnode->symbol.decl)
&& !vnode->symbol.externally_visible && vnode->analyzed && !vnode->symbol.externally_visible && vnode->analyzed
&& referenced_from_other_partition_p (&vnode->symbol.ref_list, && set_referenced_from_other_partition_p (&vnode->symbol.ref_list,
set, vset)) set, vset))
promote_var (vnode); promote_var (vnode);
} }
...@@ -866,7 +939,7 @@ lto_promote_cross_file_statics (void) ...@@ -866,7 +939,7 @@ lto_promote_cross_file_statics (void)
if (const_value_known_p (vnode->symbol.decl) if (const_value_known_p (vnode->symbol.decl)
&& DECL_INITIAL (vnode->symbol.decl) && DECL_INITIAL (vnode->symbol.decl)
&& !varpool_node_in_set_p (vnode, vset) && !varpool_node_in_set_p (vnode, vset)
&& referenced_from_this_partition_p (&vnode->symbol.ref_list, set, vset) && set_referenced_from_this_partition_p (&vnode->symbol.ref_list, set, vset)
&& !pointer_set_insert (inserted, vnode)) && !pointer_set_insert (inserted, vnode))
VEC_safe_push (varpool_node_ptr, heap, promoted_initializers, vnode); VEC_safe_push (varpool_node_ptr, heap, promoted_initializers, vnode);
......
...@@ -2221,9 +2221,7 @@ execute_pass_list (struct opt_pass *pass) ...@@ -2221,9 +2221,7 @@ execute_pass_list (struct opt_pass *pass)
those node in SET. */ those node in SET. */
static void static void
ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set, ipa_write_summaries_2 (struct opt_pass *pass, struct lto_out_decl_state *state)
varpool_node_set vset,
struct lto_out_decl_state *state)
{ {
while (pass) while (pass)
{ {
...@@ -2241,7 +2239,7 @@ ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set, ...@@ -2241,7 +2239,7 @@ ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set,
pass_init_dump_file (pass); pass_init_dump_file (pass);
ipa_pass->write_summary (set,vset); ipa_pass->write_summary ();
pass_fini_dump_file (pass); pass_fini_dump_file (pass);
...@@ -2251,7 +2249,7 @@ ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set, ...@@ -2251,7 +2249,7 @@ ipa_write_summaries_2 (struct opt_pass *pass, cgraph_node_set set,
} }
if (pass->sub && pass->sub->type != GIMPLE_PASS) if (pass->sub && pass->sub->type != GIMPLE_PASS)
ipa_write_summaries_2 (pass->sub, set, vset, state); ipa_write_summaries_2 (pass->sub, state);
pass = pass->next; pass = pass->next;
} }
...@@ -2270,8 +2268,8 @@ ipa_write_summaries_1 (cgraph_node_set set, varpool_node_set vset) ...@@ -2270,8 +2268,8 @@ ipa_write_summaries_1 (cgraph_node_set set, varpool_node_set vset)
lto_push_out_decl_state (state); lto_push_out_decl_state (state);
gcc_assert (!flag_wpa); gcc_assert (!flag_wpa);
ipa_write_summaries_2 (all_regular_ipa_passes, set, vset, state); ipa_write_summaries_2 (all_regular_ipa_passes, state);
ipa_write_summaries_2 (all_lto_gen_passes, set, vset, state); ipa_write_summaries_2 (all_lto_gen_passes, state);
gcc_assert (lto_get_out_decl_state () == state); gcc_assert (lto_get_out_decl_state () == state);
lto_pop_out_decl_state (); lto_pop_out_decl_state ();
...@@ -2339,9 +2337,7 @@ ipa_write_summaries (void) ...@@ -2339,9 +2337,7 @@ ipa_write_summaries (void)
only those node in SET. */ only those node in SET. */
static void static void
ipa_write_optimization_summaries_1 (struct opt_pass *pass, cgraph_node_set set, ipa_write_optimization_summaries_1 (struct opt_pass *pass, struct lto_out_decl_state *state)
varpool_node_set vset,
struct lto_out_decl_state *state)
{ {
while (pass) while (pass)
{ {
...@@ -2359,7 +2355,7 @@ ipa_write_optimization_summaries_1 (struct opt_pass *pass, cgraph_node_set set, ...@@ -2359,7 +2355,7 @@ ipa_write_optimization_summaries_1 (struct opt_pass *pass, cgraph_node_set set,
pass_init_dump_file (pass); pass_init_dump_file (pass);
ipa_pass->write_optimization_summary (set, vset); ipa_pass->write_optimization_summary ();
pass_fini_dump_file (pass); pass_fini_dump_file (pass);
...@@ -2369,7 +2365,7 @@ ipa_write_optimization_summaries_1 (struct opt_pass *pass, cgraph_node_set set, ...@@ -2369,7 +2365,7 @@ ipa_write_optimization_summaries_1 (struct opt_pass *pass, cgraph_node_set set,
} }
if (pass->sub && pass->sub->type != GIMPLE_PASS) if (pass->sub && pass->sub->type != GIMPLE_PASS)
ipa_write_optimization_summaries_1 (pass->sub, set, vset, state); ipa_write_optimization_summaries_1 (pass->sub, state);
pass = pass->next; pass = pass->next;
} }
...@@ -2404,8 +2400,8 @@ ipa_write_optimization_summaries (cgraph_node_set set, varpool_node_set vset) ...@@ -2404,8 +2400,8 @@ ipa_write_optimization_summaries (cgraph_node_set set, varpool_node_set vset)
} }
gcc_assert (flag_wpa); gcc_assert (flag_wpa);
ipa_write_optimization_summaries_1 (all_regular_ipa_passes, set, vset, state); ipa_write_optimization_summaries_1 (all_regular_ipa_passes, state);
ipa_write_optimization_summaries_1 (all_lto_gen_passes, set, vset, state); ipa_write_optimization_summaries_1 (all_lto_gen_passes, state);
gcc_assert (lto_get_out_decl_state () == state); gcc_assert (lto_get_out_decl_state () == state);
lto_pop_out_decl_state (); lto_pop_out_decl_state ();
......
...@@ -106,15 +106,13 @@ struct ipa_opt_pass_d ...@@ -106,15 +106,13 @@ struct ipa_opt_pass_d
void (*generate_summary) (void); void (*generate_summary) (void);
/* This hook is used to serialize IPA summaries on disk. */ /* This hook is used to serialize IPA summaries on disk. */
void (*write_summary) (struct cgraph_node_set_def *, void (*write_summary) (void);
struct varpool_node_set_def *);
/* This hook is used to deserialize IPA summaries from disk. */ /* This hook is used to deserialize IPA summaries from disk. */
void (*read_summary) (void); void (*read_summary) (void);
/* This hook is used to serialize IPA optimization summaries on disk. */ /* This hook is used to serialize IPA optimization summaries on disk. */
void (*write_optimization_summary) (struct cgraph_node_set_def *, void (*write_optimization_summary) (void);
struct varpool_node_set_def *);
/* This hook is used to deserialize IPA summaries from disk. */ /* This hook is used to deserialize IPA summaries from disk. */
void (*read_optimization_summary) (void); void (*read_optimization_summary) (void);
......
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