for (i = 0; i < LTO_N_DECL_STREAMS; i++)
{
uint32_t size = *data++;
- tree *decls = GGC_NEWVEC (tree, size);
+ tree *decls = (tree *) xcalloc (size, sizeof (tree));
for (j = 0; j < size; j++)
{
/* Read in per-function decl states and enter them in hash table. */
decl_data->function_decl_states =
- htab_create_ggc (37, lto_hash_in_decl_state, lto_eq_in_decl_state, NULL);
+ htab_create (37, lto_hash_in_decl_state, lto_eq_in_decl_state, free);
for (i = 1; i < num_decl_states; i++)
{
resolutions = lto_resolution_read (resolution_file, file);
- file_data = GGC_NEW (struct lto_file_decl_data);
+ file_data = XCNEW (struct lto_file_decl_data);
file_data->file_name = file->filename;
file_data->section_hash_table = lto_obj_build_section_table (file);
file_data->renaming_hash_table = lto_create_renaming_table ();
for (vnode = varpool_nodes; vnode; vnode = vnode->next)
{
- if (vnode->alias || !vnode->needed)
+ if (vnode->alias)
continue;
slot = pointer_map_contains (vpmap, file_data);
if (slot)
struct varpool_node *vnode;
unsigned i, n_sets;
cgraph_node_set set;
- varpool_node_set vset;
cgraph_node_set_iterator csi;
- varpool_node_set_iterator vsi;
gcc_assert (flag_wpa);
+ /* At moment we make no attempt to figure out who is refering the variables,
+ so all must become global. */
+ for (vnode = varpool_nodes; vnode; vnode = vnode->next)
+ if (!vnode->externally_visible && vnode->analyzed)
+ {
+ TREE_PUBLIC (vnode->decl) = 1;
+ DECL_VISIBILITY (vnode->decl) = VISIBILITY_HIDDEN;
+ }
n_sets = VEC_length (cgraph_node_set, lto_cgraph_node_sets);
for (i = 0; i < n_sets; i++)
{
set = VEC_index (cgraph_node_set, lto_cgraph_node_sets, i);
- vset = VEC_index (varpool_node_set, lto_varpool_node_sets, i);
/* If node has either address taken (and we have no clue from where)
or it is called from other partition, it needs to be globalized. */
for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
{
struct cgraph_node *node = csi_node (csi);
- bool globalize = node->local.vtable_method;
+ bool globalize = node->address_taken || node->local.vtable_method;
struct cgraph_edge *e;
if (node->local.externally_visible)
continue;
- if (!globalize
- && referenced_from_other_partition_p (&node->ref_list, set, vset))
- globalize = true;
for (e = node->callers; e && !globalize; e = e->next_caller)
{
struct cgraph_node *caller = e->caller;
}
if (globalize)
{
- gcc_assert (flag_wpa);
TREE_PUBLIC (node->decl) = 1;
DECL_VISIBILITY (node->decl) = VISIBILITY_HIDDEN;
if (node->same_body)
}
}
}
- for (vsi = vsi_start (vset); !vsi_end_p (vsi); vsi_next (&vsi))
- {
- vnode = vsi_node (vsi);
- /* Constant pool references use internal labels and thus can not
- be made global. It is sensible to keep those ltrans local to
- allow better optimization. */
- if (!DECL_IN_CONSTANT_POOL (vnode->decl)
- && !vnode->externally_visible && vnode->analyzed
- && referenced_from_other_partition_p (&vnode->ref_list, set, vset))
- {
- gcc_assert (flag_wpa);
- TREE_PUBLIC (vnode->decl) = 1;
- DECL_VISIBILITY (vnode->decl) = VISIBILITY_HIDDEN;
- }
- }
}
}
char *fname = NULL;
static const size_t max_fname_len = 100;
- /* Create a new temporary file to store SET. To facilitate
- debugging, use file names from SET as part of the new
- temporary file name. */
- cgraph_node_set_iterator si;
- struct pointer_set_t *pset = pointer_set_create ();
- for (si = csi_start (set); !csi_end_p (si); csi_next (&si))
+ if (cgraph_node_set_needs_ltrans_p (set))
{
- struct cgraph_node *n = csi_node (si);
- const char *node_fname;
- char *f;
+ /* Create a new temporary file to store SET. To facilitate
+ debugging, use file names from SET as part of the new
+ temporary file name. */
+ cgraph_node_set_iterator si;
+ struct pointer_set_t *pset = pointer_set_create ();
+ for (si = csi_start (set); !csi_end_p (si); csi_next (&si))
+ {
+ struct cgraph_node *n = csi_node (si);
+ const char *node_fname;
+ char *f;
- /* Don't use the same file name more than once. */
- if (pointer_set_insert (pset, n->local.lto_file_data))
- continue;
+ /* Don't use the same file name more than once. */
+ if (pointer_set_insert (pset, n->local.lto_file_data))
+ continue;
- /* The first file name found in SET determines the output
- directory. For the remaining files, we use their
- base names. */
- node_fname = n->local.lto_file_data->file_name;
- if (fname == NULL)
- {
- fname = strip_extension (node_fname);
- continue;
- }
+ /* The first file name found in SET determines the output
+ directory. For the remaining files, we use their
+ base names. */
+ node_fname = n->local.lto_file_data->file_name;
+ if (fname == NULL)
+ {
+ fname = strip_extension (node_fname);
+ continue;
+ }
- f = strip_extension (lbasename (node_fname));
+ f = strip_extension (lbasename (node_fname));
- /* If the new name causes an excessively long file name,
- make the last component "___" to indicate overflow. */
- if (strlen (fname) + strlen (f) > max_fname_len - 3)
- {
- fname = reconcat (fname, fname, "___", NULL);
- break;
- }
- else
- {
- fname = reconcat (fname, fname, "_", f, NULL);
- free (f);
+ /* If the new name causes an excessively long file name,
+ make the last component "___" to indicate overflow. */
+ if (strlen (fname) + strlen (f) > max_fname_len - 3)
+ {
+ fname = reconcat (fname, fname, "___", NULL);
+ break;
+ }
+ else
+ {
+ fname = reconcat (fname, fname, "_", f, NULL);
+ free (f);
+ }
}
- }
- pointer_set_destroy (pset);
+ pointer_set_destroy (pset);
- if (!fname)
+ /* Add the extension .wpa.o to indicate that this file has been
+ produced by WPA. */
+ fname = reconcat (fname, fname, ".wpa.o", NULL);
+ gcc_assert (fname);
+ }
+ else
{
/* Since SET does not need to be processed by LTRANS, use
the original file name and mark it with a '*' prefix so that
struct cgraph_node *first = csi_node (si);
fname = prefix_name_with_star (first->local.lto_file_data->file_name);
}
- else
- {
- /* Add the extension .wpa.o to indicate that this file has been
- produced by WPA. */
- fname = reconcat (fname, fname, ".wpa.o", NULL);
- gcc_assert (fname);
- }
return fname;
}
temp_filename = get_filename_for_set (set);
output_files[i] = temp_filename;
- if (cgraph_node_set_nonempty_p (set) || varpool_node_set_nonempty_p (vset))
+ if (cgraph_node_set_needs_ltrans_p (set))
{
/* Write all the nodes in SET to TEMP_FILENAME. */
file = lto_obj_file_open (temp_filename, true);
if (!file)
fatal_error ("lto_obj_file_open() failed");
- if (!quiet_flag)
- fprintf (stderr, " %s", temp_filename);
-
lto_set_current_out_file (file);
ipa_write_optimization_summaries (set, vset);
t = *tp;
*walk_subtrees = 0;
- if (!t || pointer_set_contains (fixup_data->seen, t))
+ if (pointer_set_contains (fixup_data->seen, t))
return NULL;
if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == FUNCTION_DECL)
lto_reissue_options ();
}
-static GTY((length ("lto_stats.num_input_files + 1"))) struct lto_file_decl_data **all_file_decl_data;
/* Read all the symbols from the input files FNAMES. NFILES is the
number of files requested in the command line. Instantiate a
read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
{
unsigned int i, last_file_ix;
+ struct lto_file_decl_data **all_file_decl_data;
FILE *resolution;
struct cgraph_node *node;
timevar_push (TV_IPA_LTO_DECL_IO);
/* Set the hooks so that all of the ipa passes can read in their data. */
- all_file_decl_data = GGC_CNEWVEC (struct lto_file_decl_data *, nfiles + 1);
+ all_file_decl_data = XNEWVEC (struct lto_file_decl_data *, nfiles + 1);
lto_set_in_hooks (all_file_decl_data, get_section_data, free_section_data);
/* Read the resolution file. */
lto_obj_file_close (current_lto_file);
current_lto_file = NULL;
- ggc_collect ();
}
if (resolution_file_name)
/* Set the hooks so that all of the ipa passes can read in their data. */
lto_set_in_hooks (all_file_decl_data, get_section_data, free_section_data);
+ /* Each pass will set the appropriate timer. */
timevar_pop (TV_IPA_LTO_DECL_IO);
if (!quiet_flag)
fprintf (stderr, "\nReading the callgraph\n");
- timevar_push (TV_IPA_LTO_CGRAPH_IO);
/* Read the callgraph. */
input_cgraph ();
- timevar_pop (TV_IPA_LTO_CGRAPH_IO);
if (!quiet_flag)
fprintf (stderr, "Merging declarations\n");
- timevar_push (TV_IPA_LTO_DECL_MERGE);
/* Merge global decls. */
lto_symtab_merge_decls ();
/* Fixup all decls and types and free the type hash tables. */
lto_fixup_decls (all_file_decl_data);
free_gimple_type_tables ();
- ggc_collect ();
-
- timevar_pop (TV_IPA_LTO_DECL_MERGE);
- /* Each pass will set the appropriate timer. */
if (!quiet_flag)
fprintf (stderr, "Reading summaries\n");
ipa_read_summaries ();
/* Finally merge the cgraph according to the decl merging decisions. */
- timevar_push (TV_IPA_LTO_CGRAPH_MERGE);
lto_symtab_merge_cgraph_nodes ();
- ggc_collect ();
if (flag_ltrans)
for (node = cgraph_nodes; node; node = node->next)
node->ipa_transforms_to_apply,
(ipa_opt_pass)&pass_ipa_inline);
}
- timevar_pop (TV_IPA_LTO_CGRAPH_MERGE);
- timevar_push (TV_IPA_LTO_DECL_INIT_IO);
+ timevar_push (TV_IPA_LTO_DECL_IO);
/* FIXME lto. This loop needs to be changed to use the pass manager to
call the ipa passes directly. */
/* Indicate that the cgraph is built and ready. */
cgraph_function_flags_ready = true;
- timevar_pop (TV_IPA_LTO_DECL_INIT_IO);
- ggc_free (all_file_decl_data);
- all_file_decl_data = NULL;
+ timevar_pop (TV_IPA_LTO_DECL_IO);
}
/* Reading in the cgraph uses different timers, start timing WPA now. */
timevar_push (TV_WHOPR_WPA);
- if (pre_ipa_mem_report)
- {
- fprintf (stderr, "Memory consumption before IPA\n");
- dump_memory_report (false);
- }
-
cgraph_function_flags_ready = true;
bitmap_obstack_initialize (NULL);
ipa_register_cgraph_hooks ();
fflush (stderr);
}
output_files = lto_wpa_write_files ();
- ggc_collect ();
if (!quiet_flag)
fprintf (stderr, "\n");
- if (post_ipa_mem_report)
- {
- fprintf (stderr, "Memory consumption after IPA\n");
- dump_memory_report (false);
- }
-
/* Show the LTO report before launching LTRANS. */
if (flag_lto_report)
print_lto_report ();