Commit ee7a003f by Martin Liska Committed by Martin Liska

Fix GNU coding style in lto-common.c.

2019-05-06  Martin Liska  <mliska@suse.cz>

	* lto-common.c: Update coding style.
	* lto.c (materialize_cgraph): Likewise.

From-SVN: r270898
parent 66d62d9f
2019-05-06 Martin Liska <mliska@suse.cz>
* lto-common.c: Update coding style.
* lto.c (materialize_cgraph): Likewise.
2019-05-06 Hrishikesh Kulkarni <hrishikeshparag@gmail.com> 2019-05-06 Hrishikesh Kulkarni <hrishikeshparag@gmail.com>
Martin Liska <mliska@suse.cz> Martin Liska <mliska@suse.cz>
......
...@@ -76,15 +76,15 @@ hash_name (const void *p) ...@@ -76,15 +76,15 @@ hash_name (const void *p)
static int static int
eq_name (const void *p1, const void *p2) eq_name (const void *p1, const void *p2)
{ {
const struct lto_section_slot *s1 = const struct lto_section_slot *s1
(const struct lto_section_slot *) p1; = (const struct lto_section_slot *) p1;
const struct lto_section_slot *s2 = const struct lto_section_slot *s2
(const struct lto_section_slot *) p2; = (const struct lto_section_slot *) p2;
return strcmp (s1->name, s2->name) == 0; return strcmp (s1->name, s2->name) == 0;
} }
/* Free lto_section_slot */ /* Free lto_section_slot. */
static void static void
free_with_string (void *arg) free_with_string (void *arg)
...@@ -95,9 +95,9 @@ free_with_string (void *arg) ...@@ -95,9 +95,9 @@ free_with_string (void *arg)
free (arg); free (arg);
} }
/* Create section hash table */ /* Create section hash table. */
htab_t htab_t
lto_obj_create_section_hash_table (void) lto_obj_create_section_hash_table (void)
{ {
return htab_create (37, hash_name, eq_name, free_with_string); return htab_create (37, hash_name, eq_name, free_with_string);
...@@ -145,9 +145,9 @@ lto_splay_tree_id_equal_p (splay_tree_key key, unsigned HOST_WIDE_INT id) ...@@ -145,9 +145,9 @@ lto_splay_tree_id_equal_p (splay_tree_key key, unsigned HOST_WIDE_INT id)
return *(unsigned HOST_WIDE_INT *) key == id; return *(unsigned HOST_WIDE_INT *) key == id;
} }
/* Insert a splay tree node into tree T with ID as key and FILE_DATA as value. /* Insert a splay tree node into tree T with ID as key and FILE_DATA as value.
The ID is allocated separately because we need HOST_WIDE_INTs which may The ID is allocated separately because we need HOST_WIDE_INTs which may
be wider than a splay_tree_key. */ be wider than a splay_tree_key. */
static void static void
lto_splay_tree_insert (splay_tree t, unsigned HOST_WIDE_INT id, lto_splay_tree_insert (splay_tree t, unsigned HOST_WIDE_INT id,
...@@ -164,13 +164,13 @@ static splay_tree ...@@ -164,13 +164,13 @@ static splay_tree
lto_splay_tree_new (void) lto_splay_tree_new (void)
{ {
return splay_tree_new (lto_splay_tree_compare_ids, return splay_tree_new (lto_splay_tree_compare_ids,
lto_splay_tree_delete_id, lto_splay_tree_delete_id,
NULL); NULL);
} }
/* Decode the content of memory pointed to by DATA in the in decl /* Decode the content of memory pointed to by DATA in the in decl
state object STATE. DATA_IN points to a data_in structure for state object STATE. DATA_IN points to a data_in structure for
decoding. Return the address after the decoded object in the decoding. Return the address after the decoded object in the
input. */ input. */
static const uint32_t * static const uint32_t *
...@@ -255,7 +255,7 @@ hash_canonical_type (tree type) ...@@ -255,7 +255,7 @@ hash_canonical_type (tree type)
{ {
hstate.add_int (TYPE_PRECISION (type)); hstate.add_int (TYPE_PRECISION (type));
if (!type_with_interoperable_signedness (type)) if (!type_with_interoperable_signedness (type))
hstate.add_int (TYPE_UNSIGNED (type)); hstate.add_int (TYPE_UNSIGNED (type));
} }
if (VECTOR_TYPE_P (type)) if (VECTOR_TYPE_P (type))
...@@ -437,8 +437,8 @@ gimple_register_canonical_type (tree t) ...@@ -437,8 +437,8 @@ gimple_register_canonical_type (tree t)
TYPE_CANONICAL (t) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t)); TYPE_CANONICAL (t) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t));
else else
{ {
gimple_register_canonical_type_1 (TYPE_MAIN_VARIANT (t), hashval_t h = hash_canonical_type (TYPE_MAIN_VARIANT (t));
hash_canonical_type (TYPE_MAIN_VARIANT (t))); gimple_register_canonical_type_1 (TYPE_MAIN_VARIANT (t), h);
TYPE_CANONICAL (t) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t)); TYPE_CANONICAL (t) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t));
} }
} }
...@@ -460,7 +460,7 @@ lto_register_canonical_types (tree node, bool first_p) ...@@ -460,7 +460,7 @@ lto_register_canonical_types (tree node, bool first_p)
|| TREE_CODE (node) == ARRAY_TYPE) || TREE_CODE (node) == ARRAY_TYPE)
lto_register_canonical_types (TREE_TYPE (node), first_p); lto_register_canonical_types (TREE_TYPE (node), first_p);
if (!first_p) if (!first_p)
gimple_register_canonical_type (node); gimple_register_canonical_type (node);
} }
...@@ -534,7 +534,7 @@ mentions_vars_p_decl_with_vis (tree t) ...@@ -534,7 +534,7 @@ mentions_vars_p_decl_with_vis (tree t)
if (mentions_vars_p_decl_common (t)) if (mentions_vars_p_decl_common (t))
return true; return true;
/* Accessor macro has side-effects, use field-name here. */ /* Accessor macro has side-effects, use field-name here. */
CHECK_NO_VAR (DECL_ASSEMBLER_NAME_RAW (t)); CHECK_NO_VAR (DECL_ASSEMBLER_NAME_RAW (t));
return false; return false;
} }
...@@ -594,7 +594,7 @@ mentions_vars_p_type (tree t) ...@@ -594,7 +594,7 @@ mentions_vars_p_type (tree t)
CHECK_VAR (TYPE_MIN_VALUE_RAW (t)); CHECK_VAR (TYPE_MIN_VALUE_RAW (t));
CHECK_VAR (TYPE_MAX_VALUE_RAW (t)); CHECK_VAR (TYPE_MAX_VALUE_RAW (t));
/* Accessor is for derived node types only. */ /* Accessor is for derived node types only. */
CHECK_NO_VAR (TYPE_LANG_SLOT_1 (t)); CHECK_NO_VAR (TYPE_LANG_SLOT_1 (t));
CHECK_VAR (TYPE_CONTEXT (t)); CHECK_VAR (TYPE_CONTEXT (t));
...@@ -748,7 +748,7 @@ mentions_vars_p (tree t) ...@@ -748,7 +748,7 @@ mentions_vars_p (tree t)
} }
/* Return the resolution for the decl with index INDEX from DATA_IN. */ /* Return the resolution for the decl with index INDEX from DATA_IN. */
static enum ld_plugin_symbol_resolution static enum ld_plugin_symbol_resolution
get_resolution (struct data_in *data_in, unsigned index) get_resolution (struct data_in *data_in, unsigned index)
...@@ -758,7 +758,7 @@ get_resolution (struct data_in *data_in, unsigned index) ...@@ -758,7 +758,7 @@ get_resolution (struct data_in *data_in, unsigned index)
ld_plugin_symbol_resolution_t ret; ld_plugin_symbol_resolution_t ret;
/* We can have references to not emitted functions in /* We can have references to not emitted functions in
DECL_FUNCTION_PERSONALITY at least. So we can and have DECL_FUNCTION_PERSONALITY at least. So we can and have
to indeed return LDPR_UNKNOWN in some cases. */ to indeed return LDPR_UNKNOWN in some cases. */
if (data_in->globals_resolution.length () <= index) if (data_in->globals_resolution.length () <= index)
return LDPR_UNKNOWN; return LDPR_UNKNOWN;
ret = data_in->globals_resolution[index]; ret = data_in->globals_resolution[index];
...@@ -1090,7 +1090,7 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map) ...@@ -1090,7 +1090,7 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
if (code == VAR_DECL) if (code == VAR_DECL)
{ {
compare_values (DECL_HARD_REGISTER); compare_values (DECL_HARD_REGISTER);
/* DECL_IN_TEXT_SECTION is set during final asm output only. */ /* DECL_IN_TEXT_SECTION is set during final asm output only. */
compare_values (DECL_IN_CONSTANT_POOL); compare_values (DECL_IN_CONSTANT_POOL);
} }
} }
...@@ -1143,8 +1143,8 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map) ...@@ -1143,8 +1143,8 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
compare_values (TYPE_PRECISION); compare_values (TYPE_PRECISION);
compare_values (TYPE_ALIGN); compare_values (TYPE_ALIGN);
/* Do not compare TYPE_ALIAS_SET. Doing so introduce ordering issues /* Do not compare TYPE_ALIAS_SET. Doing so introduce ordering issues
with calls to get_alias_set which may initialize it for streamed with calls to get_alias_set which may initialize it for streamed
in types. */ in types. */
} }
/* We don't want to compare locations, so there is nothing do compare /* We don't want to compare locations, so there is nothing do compare
...@@ -1479,7 +1479,7 @@ compare_tree_sccs (tree_scc *pscc, tree_scc *scc, ...@@ -1479,7 +1479,7 @@ compare_tree_sccs (tree_scc *pscc, tree_scc *scc,
return true; return true;
} }
/* Reset TREE_ASM_WRITTEN on scc for the next compare or in case /* Reset TREE_ASM_WRITTEN on scc for the next compare or in case
the SCC prevails. */ the SCC prevails. */
for (unsigned j = 0; j < scc->len; ++j) for (unsigned j = 0; j < scc->len; ++j)
TREE_ASM_WRITTEN (scc->entries[j]) = 0; TREE_ASM_WRITTEN (scc->entries[j]) = 0;
} }
...@@ -1582,7 +1582,7 @@ unify_scc (struct data_in *data_in, unsigned from, ...@@ -1582,7 +1582,7 @@ unify_scc (struct data_in *data_in, unsigned from,
if (len == 1) if (len == 1)
{ {
/* If we got a debug reference queued, see if the prevailing /* If we got a debug reference queued, see if the prevailing
tree has a debug reference and if not, register the one tree has a debug reference and if not, register the one
for the tree we are about to throw away. */ for the tree we are about to throw away. */
if (dref_queue.length () == 1) if (dref_queue.length () == 1)
{ {
...@@ -1807,19 +1807,19 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, ...@@ -1807,19 +1807,19 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data,
data_in->location_cache.apply_location_cache (); data_in->location_cache.apply_location_cache ();
/* Read in lto_in_decl_state objects. */ /* Read in lto_in_decl_state objects. */
data_ptr = (const uint32_t *) ((const char*) data + decl_offset); data_ptr = (const uint32_t *) ((const char*) data + decl_offset);
data_end = data_end
(const uint32_t *) ((const char*) data_ptr + header->decl_state_size); = (const uint32_t *) ((const char*) data_ptr + header->decl_state_size);
num_decl_states = *data_ptr++; num_decl_states = *data_ptr++;
gcc_assert (num_decl_states > 0); gcc_assert (num_decl_states > 0);
decl_data->global_decl_state = lto_new_in_decl_state (); decl_data->global_decl_state = lto_new_in_decl_state ();
data_ptr = lto_read_in_decl_state (data_in, data_ptr, data_ptr = lto_read_in_decl_state (data_in, data_ptr,
decl_data->global_decl_state); decl_data->global_decl_state);
/* Read in per-function decl states and enter them in hash table. */ /* Read in per-function decl states and enter them in hash table. */
decl_data->function_decl_states = decl_data->function_decl_states
hash_table<decl_state_hasher>::create_ggc (37); = hash_table<decl_state_hasher>::create_ggc (37);
for (i = 1; i < num_decl_states; i++) for (i = 1; i < num_decl_states; i++)
{ {
...@@ -1835,7 +1835,7 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data, ...@@ -1835,7 +1835,7 @@ lto_read_decls (struct lto_file_decl_data *decl_data, const void *data,
if (data_ptr != data_end) if (data_ptr != data_end)
internal_error ("bytecode stream: garbage at the end of symbols section"); internal_error ("bytecode stream: garbage at the end of symbols section");
/* Set the current decl state to be the global state. */ /* Set the current decl state to be the global state. */
decl_data->current_decl_state = decl_data->global_decl_state; decl_data->current_decl_state = decl_data->global_decl_state;
lto_data_in_delete (data_in); lto_data_in_delete (data_in);
...@@ -1854,40 +1854,40 @@ lto_parse_hex (const char *p) ...@@ -1854,40 +1854,40 @@ lto_parse_hex (const char *p)
unsigned char part; unsigned char part;
ret <<= 4; ret <<= 4;
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
part = c - '0'; part = c - '0';
else if (c >= 'a' && c <= 'f') else if (c >= 'a' && c <= 'f')
part = c - 'a' + 10; part = c - 'a' + 10;
else if (c >= 'A' && c <= 'F') else if (c >= 'A' && c <= 'F')
part = c - 'A' + 10; part = c - 'A' + 10;
else else
internal_error ("could not parse hex number"); internal_error ("could not parse hex number");
ret |= part; ret |= part;
} }
return ret; return ret;
} }
/* Read resolution for file named FILE_NAME. The resolution is read from /* Read resolution for file named FILE_NAME. The resolution is read from
RESOLUTION. */ RESOLUTION. */
static void static void
lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file) lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file)
{ {
/* We require that objects in the resolution file are in the same /* We require that objects in the resolution file are in the same
order as the lto1 command line. */ order as the lto1 command line. */
unsigned int name_len; unsigned int name_len;
char *obj_name; char *obj_name;
unsigned int num_symbols; unsigned int num_symbols;
unsigned int i; unsigned int i;
struct lto_file_decl_data *file_data; struct lto_file_decl_data *file_data;
splay_tree_node nd = NULL; splay_tree_node nd = NULL;
if (!resolution) if (!resolution)
return; return;
name_len = strlen (file->filename); name_len = strlen (file->filename);
obj_name = XNEWVEC (char, name_len + 1); obj_name = XNEWVEC (char, name_len + 1);
fscanf (resolution, " "); /* Read white space. */ fscanf (resolution, " "); /* Read white space. */
fread (obj_name, sizeof (char), name_len, resolution); fread (obj_name, sizeof (char), name_len, resolution);
obj_name[name_len] = '\0'; obj_name[name_len] = '\0';
...@@ -1901,10 +1901,10 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file) ...@@ -1901,10 +1901,10 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file)
int64_t offset; int64_t offset;
t = fscanf (resolution, "@0x%16s", offset_p); t = fscanf (resolution, "@0x%16s", offset_p);
if (t != 1) if (t != 1)
internal_error ("could not parse file offset"); internal_error ("could not parse file offset");
offset = lto_parse_hex (offset_p); offset = lto_parse_hex (offset_p);
if (offset != file->offset) if (offset != file->offset)
internal_error ("unexpected offset"); internal_error ("unexpected offset");
} }
free (obj_name); free (obj_name);
...@@ -1919,14 +1919,14 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file) ...@@ -1919,14 +1919,14 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file)
char r_str[27]; char r_str[27];
enum ld_plugin_symbol_resolution r = (enum ld_plugin_symbol_resolution) 0; enum ld_plugin_symbol_resolution r = (enum ld_plugin_symbol_resolution) 0;
unsigned int j; unsigned int j;
unsigned int lto_resolution_str_len = unsigned int lto_resolution_str_len
sizeof (lto_resolution_str) / sizeof (char *); = sizeof (lto_resolution_str) / sizeof (char *);
res_pair rp; res_pair rp;
t = fscanf (resolution, "%u " HOST_WIDE_INT_PRINT_HEX_PURE " %26s %*[^\n]\n", t = fscanf (resolution, "%u " HOST_WIDE_INT_PRINT_HEX_PURE
&index, &id, r_str); " %26s %*[^\n]\n", &index, &id, r_str);
if (t != 3) if (t != 3)
internal_error ("invalid line in the resolution file"); internal_error ("invalid line in the resolution file");
for (j = 0; j < lto_resolution_str_len; j++) for (j = 0; j < lto_resolution_str_len; j++)
{ {
...@@ -1947,25 +1947,25 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file) ...@@ -1947,25 +1947,25 @@ lto_resolution_read (splay_tree file_ids, FILE *resolution, lto_file *file)
} }
file_data = (struct lto_file_decl_data *)nd->value; file_data = (struct lto_file_decl_data *)nd->value;
/* The indexes are very sparse. To save memory save them in a compact /* The indexes are very sparse. To save memory save them in a compact
format that is only unpacked later when the subfile is processed. */ format that is only unpacked later when the subfile is processed. */
rp.res = r; rp.res = r;
rp.index = index; rp.index = index;
file_data->respairs.safe_push (rp); file_data->respairs.safe_push (rp);
if (file_data->max_index < index) if (file_data->max_index < index)
file_data->max_index = index; file_data->max_index = index;
} }
} }
/* List of file_decl_datas */ /* List of file_decl_datas. */
struct file_data_list struct file_data_list
{ {
struct lto_file_decl_data *first, *last; struct lto_file_decl_data *first, *last;
}; };
/* Is the name for a id'ed LTO section? */ /* Is the name for a id'ed LTO section? */
static int static int
lto_section_with_id (const char *name, unsigned HOST_WIDE_INT *id) lto_section_with_id (const char *name, unsigned HOST_WIDE_INT *id)
{ {
const char *s; const char *s;
...@@ -1981,11 +1981,11 @@ lto_section_with_id (const char *name, unsigned HOST_WIDE_INT *id) ...@@ -1981,11 +1981,11 @@ lto_section_with_id (const char *name, unsigned HOST_WIDE_INT *id)
return sscanf (s, "." HOST_WIDE_INT_PRINT_HEX_PURE, id) == 1; return sscanf (s, "." HOST_WIDE_INT_PRINT_HEX_PURE, id) == 1;
} }
/* Create file_data of each sub file id */ /* Create file_data of each sub file id. */
static int static int
create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids, create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids,
struct file_data_list *list) struct file_data_list *list)
{ {
struct lto_section_slot s_slot, *new_slot; struct lto_section_slot s_slot, *new_slot;
unsigned HOST_WIDE_INT id; unsigned HOST_WIDE_INT id;
...@@ -1996,8 +1996,8 @@ create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids, ...@@ -1996,8 +1996,8 @@ create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids,
if (!lto_section_with_id (ls->name, &id)) if (!lto_section_with_id (ls->name, &id))
return 1; return 1;
/* Find hash table of sub module id */ /* Find hash table of sub module id. */
nd = lto_splay_tree_lookup (file_ids, id); nd = lto_splay_tree_lookup (file_ids, id);
if (nd != NULL) if (nd != NULL)
{ {
...@@ -2011,15 +2011,16 @@ create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids, ...@@ -2011,15 +2011,16 @@ create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids,
file_data->section_hash_table = lto_obj_create_section_hash_table (); file_data->section_hash_table = lto_obj_create_section_hash_table ();
lto_splay_tree_insert (file_ids, id, file_data); lto_splay_tree_insert (file_ids, id, file_data);
/* Maintain list in linker order */ /* Maintain list in linker order. */
if (!list->first) if (!list->first)
list->first = file_data; list->first = file_data;
if (list->last) if (list->last)
list->last->next = file_data; list->last->next = file_data;
list->last = file_data; list->last = file_data;
} }
/* Copy section into sub module hash table */ /* Copy section into sub module hash table. */
new_name = XDUPVEC (char, ls->name, strlen (ls->name) + 1); new_name = XDUPVEC (char, ls->name, strlen (ls->name) + 1);
s_slot.name = new_name; s_slot.name = new_name;
hash_slot = htab_find_slot (file_data->section_hash_table, &s_slot, INSERT); hash_slot = htab_find_slot (file_data->section_hash_table, &s_slot, INSERT);
...@@ -2031,7 +2032,7 @@ create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids, ...@@ -2031,7 +2032,7 @@ create_subid_section_table (struct lto_section_slot *ls, splay_tree file_ids,
return 1; return 1;
} }
/* Read declarations and other initializations for a FILE_DATA. */ /* Read declarations and other initializations for a FILE_DATA. */
static void static void
lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file) lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file)
...@@ -2043,8 +2044,8 @@ lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file) ...@@ -2043,8 +2044,8 @@ lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file)
int i; int i;
res_pair *rp; res_pair *rp;
/* Create vector for fast access of resolution. We do this lazily /* Create vector for fast access of resolution. We do this lazily
to save memory. */ to save memory. */
resolutions.safe_grow_cleared (file_data->max_index + 1); resolutions.safe_grow_cleared (file_data->max_index + 1);
for (i = 0; file_data->respairs.iterate (i, &rp); i++) for (i = 0; file_data->respairs.iterate (i, &rp); i++)
resolutions[rp->index] = rp->res; resolutions[rp->index] = rp->res;
...@@ -2063,14 +2064,14 @@ lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file) ...@@ -2063,14 +2064,14 @@ lto_file_finalize (struct lto_file_decl_data *file_data, lto_file *file)
internal_error ("cannot read LTO decls from %s", file_data->file_name); internal_error ("cannot read LTO decls from %s", file_data->file_name);
return; return;
} }
/* Frees resolutions */ /* Frees resolutions. */
lto_read_decls (file_data, data, resolutions); lto_read_decls (file_data, data, resolutions);
lto_free_section_data (file_data, LTO_section_decls, NULL, data, len); lto_free_section_data (file_data, LTO_section_decls, NULL, data, len);
} }
/* Finalize FILE_DATA in FILE and increase COUNT. */ /* Finalize FILE_DATA in FILE and increase COUNT. */
static int static int
lto_create_files_from_ids (lto_file *file, struct lto_file_decl_data *file_data, lto_create_files_from_ids (lto_file *file, struct lto_file_decl_data *file_data,
int *count) int *count)
{ {
...@@ -2084,11 +2085,11 @@ lto_create_files_from_ids (lto_file *file, struct lto_file_decl_data *file_data, ...@@ -2084,11 +2085,11 @@ lto_create_files_from_ids (lto_file *file, struct lto_file_decl_data *file_data,
} }
/* Generate a TREE representation for all types and external decls /* Generate a TREE representation for all types and external decls
entities in FILE. entities in FILE.
Read all of the globals out of the file. Then read the cgraph Read all of the globals out of the file. Then read the cgraph
and process the .o index into the cgraph nodes so that it can open and process the .o index into the cgraph nodes so that it can open
the .o file to load the functions and ipa information. */ the .o file to load the functions and ipa information. */
static struct lto_file_decl_data * static struct lto_file_decl_data *
lto_file_read (lto_file *file, FILE *resolution_file, int *count) lto_file_read (lto_file *file, FILE *resolution_file, int *count)
...@@ -2099,8 +2100,8 @@ lto_file_read (lto_file *file, FILE *resolution_file, int *count) ...@@ -2099,8 +2100,8 @@ lto_file_read (lto_file *file, FILE *resolution_file, int *count)
struct lto_section_slot *section; struct lto_section_slot *section;
struct file_data_list file_list; struct file_data_list file_list;
struct lto_section_list section_list; struct lto_section_list section_list;
memset (&section_list, 0, sizeof (struct lto_section_list)); memset (&section_list, 0, sizeof (struct lto_section_list));
section_hash_table = lto_obj_build_section_table (file, &section_list); section_hash_table = lto_obj_build_section_table (file, &section_list);
/* Dump the details of LTO objects. */ /* Dump the details of LTO objects. */
...@@ -2115,19 +2116,20 @@ lto_file_read (lto_file *file, FILE *resolution_file, int *count) ...@@ -2115,19 +2116,20 @@ lto_file_read (lto_file *file, FILE *resolution_file, int *count)
} }
/* Find all sub modules in the object and put their sections into new hash /* Find all sub modules in the object and put their sections into new hash
tables in a splay tree. */ tables in a splay tree. */
file_ids = lto_splay_tree_new (); file_ids = lto_splay_tree_new ();
memset (&file_list, 0, sizeof (struct file_data_list)); memset (&file_list, 0, sizeof (struct file_data_list));
for (section = section_list.first; section != NULL; section = section->next) for (section = section_list.first; section != NULL; section = section->next)
create_subid_section_table (section, file_ids, &file_list); create_subid_section_table (section, file_ids, &file_list);
/* Add resolutions to file ids */ /* Add resolutions to file ids. */
lto_resolution_read (file_ids, resolution_file, file); lto_resolution_read (file_ids, resolution_file, file);
/* Finalize each lto file for each submodule in the merged object */ /* Finalize each lto file for each submodule in the merged object. */
for (file_data = file_list.first; file_data != NULL; file_data = file_data->next) for (file_data = file_list.first; file_data != NULL;
file_data = file_data->next)
lto_create_files_from_ids (file, file_data, count); lto_create_files_from_ids (file, file_data, count);
splay_tree_delete (file_ids); splay_tree_delete (file_ids);
htab_delete (section_hash_table); htab_delete (section_hash_table);
...@@ -2176,10 +2178,10 @@ lto_read_section_data (struct lto_file_decl_data *file_data, ...@@ -2176,10 +2178,10 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
{ {
fd = open (file_data->file_name, O_RDONLY|O_BINARY); fd = open (file_data->file_name, O_RDONLY|O_BINARY);
if (fd == -1) if (fd == -1)
{ {
fatal_error (input_location, "Cannot open %s", file_data->file_name); fatal_error (input_location, "Cannot open %s", file_data->file_name);
return NULL; return NULL;
} }
fd_name = xstrdup (file_data->file_name); fd_name = xstrdup (file_data->file_name);
} }
...@@ -2213,8 +2215,8 @@ lto_read_section_data (struct lto_file_decl_data *file_data, ...@@ -2213,8 +2215,8 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
result = NULL; result = NULL;
} }
#ifdef __MINGW32__ #ifdef __MINGW32__
/* Native windows doesn't supports delayed unlink on opened file. So /* Native windows doesn't supports delayed unlink on opened file. So
we close file here again. This produces higher I/O load, but at least we close file here again. This produces higher I/O load, but at least
it prevents to have dangling file handles preventing unlink. */ it prevents to have dangling file handles preventing unlink. */
free (fd_name); free (fd_name);
fd_name = NULL; fd_name = NULL;
...@@ -2223,7 +2225,7 @@ lto_read_section_data (struct lto_file_decl_data *file_data, ...@@ -2223,7 +2225,7 @@ lto_read_section_data (struct lto_file_decl_data *file_data,
#endif #endif
return result; return result;
#endif #endif
} }
/* Get the section data from FILE_DATA of SECTION_TYPE with NAME. /* Get the section data from FILE_DATA of SECTION_TYPE with NAME.
...@@ -2239,7 +2241,8 @@ get_section_data (struct lto_file_decl_data *file_data, ...@@ -2239,7 +2241,8 @@ get_section_data (struct lto_file_decl_data *file_data,
htab_t section_hash_table = file_data->section_hash_table; htab_t section_hash_table = file_data->section_hash_table;
struct lto_section_slot *f_slot; struct lto_section_slot *f_slot;
struct lto_section_slot s_slot; struct lto_section_slot s_slot;
const char *section_name = lto_get_section_name (section_type, name, file_data); const char *section_name = lto_get_section_name (section_type, name,
file_data);
char *data = NULL; char *data = NULL;
*len = 0; *len = 0;
...@@ -2291,7 +2294,7 @@ static lto_file *current_lto_file; ...@@ -2291,7 +2294,7 @@ static lto_file *current_lto_file;
if ((tt) && VAR_OR_FUNCTION_DECL_P (tt) \ if ((tt) && VAR_OR_FUNCTION_DECL_P (tt) \
&& (TREE_PUBLIC (tt) || DECL_EXTERNAL (tt))) \ && (TREE_PUBLIC (tt) || DECL_EXTERNAL (tt))) \
{ \ { \
tt = lto_symtab_prevailing_decl (tt); \ tt = lto_symtab_prevailing_decl (tt); \
fixed = true; \ fixed = true; \
} \ } \
} while (0) } while (0)
...@@ -2312,7 +2315,7 @@ lto_fixup_prevailing_decls (tree t) ...@@ -2312,7 +2315,7 @@ lto_fixup_prevailing_decls (tree t)
LTO_NO_PREVAIL (TREE_TYPE (t)); LTO_NO_PREVAIL (TREE_TYPE (t));
if (CODE_CONTAINS_STRUCT (code, TS_COMMON) if (CODE_CONTAINS_STRUCT (code, TS_COMMON)
/* lto_symtab_prevail_decl use TREE_CHAIN to link to the prevailing decl. /* lto_symtab_prevail_decl use TREE_CHAIN to link to the prevailing decl.
in the case T is a prevailed declaration we would ICE here. */ in the case T is a prevailed declaration we would ICE here. */
&& !VAR_OR_FUNCTION_DECL_P (t)) && !VAR_OR_FUNCTION_DECL_P (t))
LTO_NO_PREVAIL (TREE_CHAIN (t)); LTO_NO_PREVAIL (TREE_CHAIN (t));
if (DECL_P (t)) if (DECL_P (t))
...@@ -2401,7 +2404,7 @@ lto_fixup_prevailing_decls (tree t) ...@@ -2401,7 +2404,7 @@ lto_fixup_prevailing_decls (tree t)
#undef LTO_SET_PREVAIL #undef LTO_SET_PREVAIL
#undef LTO_NO_PREVAIL #undef LTO_NO_PREVAIL
/* Helper function of lto_fixup_decls. Walks the var and fn streams in STATE, /* Helper function of lto_fixup_decls. Walks the var and fn streams in STATE,
replaces var and function decls with the corresponding prevailing def. */ replaces var and function decls with the corresponding prevailing def. */
static void static void
...@@ -2427,7 +2430,7 @@ lto_fixup_state (struct lto_in_decl_state *state) ...@@ -2427,7 +2430,7 @@ lto_fixup_state (struct lto_in_decl_state *state)
} }
} }
/* Fix the decls from all FILES. Replaces each decl with the corresponding /* Fix the decls from all FILES. Replaces each decl with the corresponding
prevailing one. */ prevailing one. */
static void static void
...@@ -2457,10 +2460,11 @@ lto_fixup_decls (struct lto_file_decl_data **files) ...@@ -2457,10 +2460,11 @@ lto_fixup_decls (struct lto_file_decl_data **files)
static GTY((length ("lto_stats.num_input_files + 1"))) struct lto_file_decl_data **all_file_decl_data; static GTY((length ("lto_stats.num_input_files + 1"))) struct lto_file_decl_data **all_file_decl_data;
/* Turn file datas for sub files into a single array, so that they look /* Turn file datas for sub files into a single array, so that they look
like separate files for further passes. */ like separate files for further passes. */
static void static void
lto_flatten_files (struct lto_file_decl_data **orig, int count, int last_file_ix) lto_flatten_files (struct lto_file_decl_data **orig, int count,
int last_file_ix)
{ {
struct lto_file_decl_data *n, *next; struct lto_file_decl_data *n, *next;
int i, k; int i, k;
...@@ -2470,7 +2474,7 @@ lto_flatten_files (struct lto_file_decl_data **orig, int count, int last_file_ix ...@@ -2470,7 +2474,7 @@ lto_flatten_files (struct lto_file_decl_data **orig, int count, int last_file_ix
= ggc_cleared_vec_alloc<lto_file_decl_data_ptr> (count + 1); = ggc_cleared_vec_alloc<lto_file_decl_data_ptr> (count + 1);
/* Set the hooks so that all of the ipa passes can read in their data. */ /* 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); lto_set_in_hooks (all_file_decl_data, get_section_data, free_section_data);
for (i = 0, k = 0; i < last_file_ix; i++) for (i = 0, k = 0; i < last_file_ix; i++)
{ {
for (n = orig[i]; n != NULL; n = next) for (n = orig[i]; n != NULL; n = next)
{ {
...@@ -2613,7 +2617,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) ...@@ -2613,7 +2617,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
delete canonical_type_hash_cache; delete canonical_type_hash_cache;
canonical_type_hash_cache = NULL; canonical_type_hash_cache = NULL;
/* At this stage we know that majority of GGC memory is reachable. /* At this stage we know that majority of GGC memory is reachable.
Growing the limits prevents unnecesary invocation of GGC. */ Growing the limits prevents unnecesary invocation of GGC. */
ggc_grow (); ggc_grow ();
ggc_collect (); ggc_collect ();
...@@ -2648,19 +2652,19 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) ...@@ -2648,19 +2652,19 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
{ {
if (snode->output_to_lto_symbol_table_p ()) if (snode->output_to_lto_symbol_table_p ())
fatal_error (input_location, "missing resolution data for %s", fatal_error (input_location, "missing resolution data for %s",
IDENTIFIER_POINTER IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (snode->decl))); (DECL_ASSEMBLER_NAME (snode->decl)));
} }
else else
snode->resolution = *res; snode->resolution = *res;
} }
for (i = 0; all_file_decl_data[i]; i++) for (i = 0; all_file_decl_data[i]; i++)
if (all_file_decl_data[i]->resolution_map) if (all_file_decl_data[i]->resolution_map)
{ {
delete all_file_decl_data[i]->resolution_map; delete all_file_decl_data[i]->resolution_map;
all_file_decl_data[i]->resolution_map = NULL; all_file_decl_data[i]->resolution_map = NULL;
} }
timevar_pop (TV_IPA_LTO_CGRAPH_IO); timevar_pop (TV_IPA_LTO_CGRAPH_IO);
if (!quiet_flag) if (!quiet_flag)
...@@ -2706,9 +2710,11 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) ...@@ -2706,9 +2710,11 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
gcc_assert (all_file_decl_data[i]->symtab_node_encoder); gcc_assert (all_file_decl_data[i]->symtab_node_encoder);
lto_symtab_encoder_delete (all_file_decl_data[i]->symtab_node_encoder); lto_symtab_encoder_delete (all_file_decl_data[i]->symtab_node_encoder);
all_file_decl_data[i]->symtab_node_encoder = NULL; all_file_decl_data[i]->symtab_node_encoder = NULL;
lto_free_function_in_decl_state (all_file_decl_data[i]->global_decl_state); lto_in_decl_state *global_decl_state
= all_file_decl_data[i]->global_decl_state;
lto_free_function_in_decl_state (global_decl_state);
all_file_decl_data[i]->global_decl_state = NULL; all_file_decl_data[i]->global_decl_state = NULL;
all_file_decl_data[i]->current_decl_state = NULL; all_file_decl_data[i]->current_decl_state = NULL;
} }
if (!flag_ltrans) if (!flag_ltrans)
...@@ -2732,7 +2738,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames) ...@@ -2732,7 +2738,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
ggc_collect (); ggc_collect ();
if (dump_file) if (dump_file)
dump_end (lto_link_dump_id, dump_file); dump_end (lto_link_dump_id, dump_file);
dump_file = NULL; dump_file = NULL;
timevar_pop (TV_IPA_LTO_CGRAPH_MERGE); timevar_pop (TV_IPA_LTO_CGRAPH_MERGE);
} }
...@@ -2838,9 +2844,9 @@ lto_eh_personality (void) ...@@ -2838,9 +2844,9 @@ lto_eh_personality (void)
return lto_eh_personality_decl; return lto_eh_personality_decl;
} }
/* Set the process name based on the LTO mode. */ /* Set the process name based on the LTO mode. */
static void static void
lto_process_name (void) lto_process_name (void)
{ {
if (flag_lto) if (flag_lto)
......
...@@ -118,7 +118,7 @@ lto_materialize_function (struct cgraph_node *node) ...@@ -118,7 +118,7 @@ lto_materialize_function (struct cgraph_node *node)
static void static void
materialize_cgraph (void) materialize_cgraph (void)
{ {
struct cgraph_node *node; struct cgraph_node *node;
timevar_id_t lto_timer; timevar_id_t lto_timer;
if (!quiet_flag) if (!quiet_flag)
...@@ -252,7 +252,7 @@ stream_out_partitions (char *temp_filename, int blen, int min, int max, ...@@ -252,7 +252,7 @@ stream_out_partitions (char *temp_filename, int blen, int min, int max,
} }
/* Fork failed; lets do the job ourseleves. */ /* Fork failed; lets do the job ourseleves. */
else if (cpid == -1) else if (cpid == -1)
stream_out_partitions_1 (temp_filename, blen, min, max); stream_out_partitions_1 (temp_filename, blen, min, max);
else else
nruns++; nruns++;
} }
...@@ -291,7 +291,8 @@ lto_wpa_write_files (void) ...@@ -291,7 +291,8 @@ lto_wpa_write_files (void)
timevar_push (TV_WHOPR_WPA); timevar_push (TV_WHOPR_WPA);
FOR_EACH_VEC_ELT (ltrans_partitions, i, part) FOR_EACH_VEC_ELT (ltrans_partitions, i, part)
lto_stats.num_output_symtab_nodes += lto_symtab_encoder_size (part->encoder); lto_stats.num_output_symtab_nodes
+= lto_symtab_encoder_size (part->encoder);
timevar_pop (TV_WHOPR_WPA); timevar_pop (TV_WHOPR_WPA);
...@@ -324,15 +325,18 @@ lto_wpa_write_files (void) ...@@ -324,15 +325,18 @@ lto_wpa_write_files (void)
sprintf (temp_filename + blen, "%u.o", i); sprintf (temp_filename + blen, "%u.o", i);
if (!quiet_flag) if (!quiet_flag)
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 (symtab->dump_file) if (symtab->dump_file)
{ {
lto_symtab_encoder_iterator lsei; lto_symtab_encoder_iterator lsei;
fprintf (symtab->dump_file, "Writing partition %s to file %s, %i insns\n", fprintf (symtab->dump_file,
"Writing partition %s to file %s, %i insns\n",
part->name, temp_filename, part->insns); part->name, temp_filename, part->insns);
fprintf (symtab->dump_file, " Symbols in partition: "); fprintf (symtab->dump_file, " Symbols in partition: ");
for (lsei = lsei_start_in_partition (part->encoder); !lsei_end_p (lsei); for (lsei = lsei_start_in_partition (part->encoder);
!lsei_end_p (lsei);
lsei_next_in_partition (&lsei)) lsei_next_in_partition (&lsei))
{ {
symtab_node *node = lsei_node (lsei); symtab_node *node = lsei_node (lsei);
...@@ -348,13 +352,15 @@ lto_wpa_write_files (void) ...@@ -348,13 +352,15 @@ lto_wpa_write_files (void)
fprintf (symtab->dump_file, "%s ", node->asm_name ()); fprintf (symtab->dump_file, "%s ", node->asm_name ());
cgraph_node *cnode = dyn_cast <cgraph_node *> (node); cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
if (cnode if (cnode
&& lto_symtab_encoder_encode_body_p (part->encoder, cnode)) && lto_symtab_encoder_encode_body_p (part->encoder,
cnode))
fprintf (symtab->dump_file, "(body included)"); fprintf (symtab->dump_file, "(body included)");
else else
{ {
varpool_node *vnode = dyn_cast <varpool_node *> (node); varpool_node *vnode = dyn_cast <varpool_node *> (node);
if (vnode if (vnode
&& lto_symtab_encoder_encode_initializer_p (part->encoder, vnode)) && lto_symtab_encoder_encode_initializer_p (part->encoder,
vnode))
fprintf (symtab->dump_file, "(initializer included)"); fprintf (symtab->dump_file, "(initializer included)");
} }
} }
...@@ -396,7 +402,7 @@ lto_wpa_write_files (void) ...@@ -396,7 +402,7 @@ lto_wpa_write_files (void)
fatal_error (input_location, fatal_error (input_location,
"closing LTRANS output list %s: %m", ltrans_output_list); "closing LTRANS output list %s: %m", ltrans_output_list);
free_ltrans_partitions(); free_ltrans_partitions ();
free (temp_filename); free (temp_filename);
timevar_pop (TV_WHOPR_WPA_IO); timevar_pop (TV_WHOPR_WPA_IO);
...@@ -634,7 +640,7 @@ lto_main (void) ...@@ -634,7 +640,7 @@ lto_main (void)
debuginfo_early_stop (); debuginfo_early_stop ();
/* Let the middle end know that we have read and merged all of /* Let the middle end know that we have read and merged all of
the input files. */ the input files. */
symtab->compile (); symtab->compile ();
timevar_stop (TV_PHASE_OPT_GEN); timevar_stop (TV_PHASE_OPT_GEN);
......
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