cgraphunit.c (handle_alias_pairs): Declare; free alias_pairs

* cgraphunit.c (handle_alias_pairs): Declare; free alias_pairs
	(cgraph_process_new_functions): Process also aliases.
	* lto-streamer-out.c (struct sets): Remove.
	(trivally_defined_alias): Remove.
	(output_alias_pair_p): Remove.
	(output_unreferenced_globals): Remove.
	(produce_symtab); Do not handle alias pairs.
	(produce_asm_for_decls): Likewise.
	* lto-streamer-in.c (input_alias_pairs): Remove.
	(lto_read_body): Do not input alias pairs.
	(lto_input_constructors_and_inits): Remove.

From-SVN: r187681
This commit is contained in:
Jan Hubicka 2012-05-19 22:36:48 +02:00 committed by Jan Hubicka
parent 38e55ac9e0
commit 877ab5e91e
6 changed files with 29 additions and 202 deletions

View File

@ -1,3 +1,17 @@
2012-05-18 Jan Hubicka <jh@suse.cz>
* cgraphunit.c (handle_alias_pairs): Declare; free alias_pairs
(cgraph_process_new_functions): Process also aliases.
* lto-streamer-out.c (struct sets): Remove.
(trivally_defined_alias): Remove.
(output_alias_pair_p): Remove.
(output_unreferenced_globals): Remove.
(produce_symtab); Do not handle alias pairs.
(produce_asm_for_decls): Likewise.
* lto-streamer-in.c (input_alias_pairs): Remove.
(lto_read_body): Do not input alias pairs.
(lto_input_constructors_and_inits): Remove.
2012-05-18 Jan Hubicka <jh@suse.cz>
* cgraphunit.c (handle_alias_pairs): Cleanup; handle all types of aliases.

View File

@ -205,6 +205,7 @@ static void expand_all_functions (void);
static void mark_functions_to_output (void);
static void expand_function (struct cgraph_node *);
static void cgraph_analyze_function (struct cgraph_node *);
static void handle_alias_pairs (void);
FILE *cgraph_dump_file;
@ -284,6 +285,8 @@ cgraph_process_new_functions (void)
if (!cgraph_new_nodes)
return false;
finish_aliases_1 ();
handle_alias_pairs ();
/* Note that this queue may grow as its being processed, as the new
functions may generate new ones. */
for (csi = csi_start (cgraph_new_nodes); !csi_end_p (csi); csi_next (&csi))
@ -1089,6 +1092,7 @@ handle_alias_pairs (void)
VEC_unordered_remove (alias_pair, alias_pairs, i);
}
}
VEC_free (alias_pair, gc, alias_pairs);
}

View File

@ -931,39 +931,6 @@ input_function (tree fn_decl, struct data_in *data_in,
}
/* Read initializer expressions for public statics. DATA_IN is the
file being read. IB is the input block used for reading. */
static void
input_alias_pairs (struct lto_input_block *ib, struct data_in *data_in)
{
tree var;
clear_line_info (data_in);
var = stream_read_tree (ib, data_in);
while (var)
{
const char *orig_name, *new_name;
alias_pair *p;
p = VEC_safe_push (alias_pair, gc, alias_pairs, NULL);
p->decl = var;
p->target = stream_read_tree (ib, data_in);
/* If the target is a static object, we may have registered a
new name for it to avoid clashes between statics coming from
different files. In that case, use the new name. */
orig_name = IDENTIFIER_POINTER (p->target);
new_name = lto_get_decl_name_mapping (data_in->file_data, orig_name);
if (strcmp (orig_name, new_name) != 0)
p->target = get_identifier (new_name);
var = stream_read_tree (ib, data_in);
}
}
/* Read the body from DATA for function FN_DECL and fill it in.
FILE_DATA are the global decls and types. SECTION_TYPE is either
LTO_section_function_body or LTO_section_static_initializer. If
@ -1059,10 +1026,6 @@ lto_read_body (struct lto_file_decl_data *file_data, tree fn_decl,
pop_cfun ();
}
else
{
input_alias_pairs (&ib_main, data_in);
}
clear_line_info (data_in);
lto_data_in_delete (data_in);
@ -1081,17 +1044,6 @@ lto_input_function_body (struct lto_file_decl_data *file_data,
}
/* Read in VAR_DECL using DATA. FILE_DATA holds the global decls and
types. */
void
lto_input_constructors_and_inits (struct lto_file_decl_data *file_data,
const char *data)
{
lto_read_body (file_data, NULL, data, LTO_section_static_initializer);
}
/* Read the physical representation of a tree node with tag TAG from
input block IB using the per-file context in DATA_IN. */

View File

@ -852,115 +852,6 @@ output_function (struct cgraph_node *node)
}
/* Used to pass data to trivally_defined_alias callback. */
struct sets {
cgraph_node_set set;
varpool_node_set vset;
};
/* Return true if alias pair P belongs to the set of cgraph nodes in
SET. If P is a an alias for a VAR_DECL, it can always be emitted.
However, for FUNCTION_DECL aliases, we should only output the pair
if it belongs to a function whose cgraph node is in SET.
Otherwise, the LTRANS phase will get into trouble when finalizing
aliases because the alias will refer to a function not defined in
the file processed by LTRANS. */
static bool
trivally_defined_alias (tree decl ATTRIBUTE_UNUSED,
tree target, void *data)
{
struct sets *set = (struct sets *) data;
struct cgraph_node *fnode = NULL;
struct varpool_node *vnode = NULL;
fnode = cgraph_node_for_asm (target);
if (fnode)
return cgraph_node_in_set_p (fnode, set->set);
vnode = varpool_node_for_asm (target);
return vnode && varpool_node_in_set_p (vnode, set->vset);
}
/* Return true if alias pair P should be output in the current
partition contains cgrpah nodes SET and varpool nodes VSET.
DEFINED is set of all aliases whose targets are defined in
the partition.
Normal aliases are output when they are defined, while WEAKREF
aliases are output when they are used. */
static bool
output_alias_pair_p (alias_pair *p, symbol_alias_set_t *defined,
cgraph_node_set set, varpool_node_set vset)
{
struct cgraph_node *node;
struct varpool_node *vnode;
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl)))
{
if (TREE_CODE (p->decl) == VAR_DECL)
{
vnode = varpool_get_node (p->decl);
return (vnode
&& referenced_from_this_partition_p (&vnode->symbol.ref_list,
set, vset));
}
node = cgraph_get_node (p->decl);
return (node
&& (referenced_from_this_partition_p (&node->symbol.ref_list,
set, vset)
|| reachable_from_this_partition_p (node, set)));
}
else
return symbol_alias_set_contains (defined, p->decl);
}
/* Output any unreferenced global symbol defined in SET, alias pairs
and labels. */
static void
output_unreferenced_globals (cgraph_node_set set, varpool_node_set vset)
{
struct output_block *ob;
alias_pair *p;
unsigned i;
symbol_alias_set_t *defined;
struct sets setdata;
setdata.set = set;
setdata.vset = vset;
ob = create_output_block (LTO_section_static_initializer);
ob->cgraph_node = NULL;
clear_line_info (ob);
/* Make string 0 be a NULL string. */
streamer_write_char_stream (ob->string_stream, 0);
/* We really need to propagate in both directoins:
for normal aliases we propagate from first defined alias to
all aliases defined based on it. For weakrefs we propagate in
the oposite direction. */
defined = propagate_aliases_backward (trivally_defined_alias, &setdata);
/* Emit the alias pairs for the nodes in SET. */
FOR_EACH_VEC_ELT (alias_pair, alias_pairs, i, p)
if (output_alias_pair_p (p, defined, set, vset))
{
stream_write_tree (ob, p->decl, true);
stream_write_tree (ob, p->target, true);
}
symbol_alias_set_destroy (defined);
streamer_write_record_start (ob, LTO_null);
produce_asm (ob, NULL);
destroy_output_block (ob);
}
/* Emit toplevel asms. */
void
@ -1387,8 +1278,7 @@ write_symbol (struct streamer_tree_cache_d *cache,
SET and VSET are cgraph/varpool node sets we are outputting. */
static void
produce_symtab (struct output_block *ob,
cgraph_node_set set, varpool_node_set vset)
produce_symtab (struct output_block *ob)
{
struct streamer_tree_cache_d *cache = ob->writer_cache;
char *section_name = lto_get_section_name (LTO_section_symtab, NULL, NULL);
@ -1399,12 +1289,6 @@ produce_symtab (struct output_block *ob,
lto_varpool_encoder_t varpool_encoder = ob->decl_state->varpool_node_encoder;
lto_cgraph_encoder_t encoder = ob->decl_state->cgraph_node_encoder;
int i;
alias_pair *p;
struct sets setdata;
symbol_alias_set_t *defined;
setdata.set = set;
setdata.vset = vset;
lto_begin_section (section_name, false);
free (section_name);
@ -1478,13 +1362,6 @@ produce_symtab (struct output_block *ob,
write_symbol (cache, &stream, vnode->symbol.decl, seen, false);
}
/* Write all aliases. */
defined = propagate_aliases_backward (trivally_defined_alias, &setdata);
FOR_EACH_VEC_ELT (alias_pair, alias_pairs, i, p)
if (output_alias_pair_p (p, defined, set, vset))
write_symbol (cache, &stream, p->decl, seen, true);
symbol_alias_set_destroy (defined);
lto_write_stream (&stream);
pointer_set_destroy (seen);
@ -1499,7 +1376,8 @@ produce_symtab (struct output_block *ob,
recover these on other side. */
static void
produce_asm_for_decls (cgraph_node_set set, varpool_node_set vset)
produce_asm_for_decls (cgraph_node_set set ATTRIBUTE_UNUSED,
varpool_node_set vset ATTRIBUTE_UNUSED)
{
struct lto_out_decl_state *out_state;
struct lto_out_decl_state *fn_out_state;
@ -1514,11 +1392,6 @@ produce_asm_for_decls (cgraph_node_set set, varpool_node_set vset)
ob = create_output_block (LTO_section_decls);
ob->global = true;
/* Write out unreferenced globals, alias pairs and labels. We defer
doing this until now so that we can write out only what is
needed. */
output_unreferenced_globals (set, vset);
memset (&header, 0, sizeof (struct lto_decl_header));
section_name = lto_get_section_name (LTO_section_decls, NULL, NULL);
@ -1528,6 +1401,8 @@ produce_asm_for_decls (cgraph_node_set set, varpool_node_set vset)
/* Make string 0 be a NULL string. */
streamer_write_char_stream (ob->string_stream, 0);
gcc_assert (!alias_pairs);
/* Write the global symbols. */
out_state = lto_get_out_decl_state ();
num_fns = VEC_length (lto_out_decl_state_ptr, lto_function_decl_states);
@ -1591,7 +1466,7 @@ produce_asm_for_decls (cgraph_node_set set, varpool_node_set vset)
/* Write the symbol table. It is used by linker to determine dependencies
and thus we can skip it for WPA. */
if (!flag_wpa)
produce_symtab (ob, set, vset);
produce_symtab (ob);
/* Write command line opts. */
lto_write_options ();

View File

@ -1,3 +1,8 @@
2012-05-18 Jan Hubicka <jh@suse.cz>
* lto.c (lto_materialize_constructors_and_inits): Remove.
(read_cgraph_and_symbols): Remove handling of alias pairs.
2012-05-17 Jan Hubicka <jh@suse.cz>
* lto-partition.c (add_references_to_partition): Handle external vars.

View File

@ -156,20 +156,6 @@ lto_splay_tree_new (void)
NULL);
}
/* Read the constructors and inits. */
static void
lto_materialize_constructors_and_inits (struct lto_file_decl_data * file_data)
{
size_t len;
const char *data = lto_get_section_data (file_data,
LTO_section_static_initializer,
NULL, &len);
lto_input_constructors_and_inits (file_data, data);
lto_free_section_data (file_data, LTO_section_static_initializer, NULL,
data, len);
}
/* Return true when NODE has a clone that is analyzed (i.e. we need
to load its body even if the node itself is not needed). */
@ -1883,15 +1869,6 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
timevar_push (TV_IPA_LTO_DECL_INIT_IO);
/* FIXME lto. This loop needs to be changed to use the pass manager to
call the ipa passes directly. */
if (!seen_error ())
for (i = 0; i < last_file_ix; i++)
{
struct lto_file_decl_data *file_data = all_file_decl_data [i];
lto_materialize_constructors_and_inits (file_data);
}
/* Indicate that the cgraph is built and ready. */
cgraph_function_flags_ready = true;