This patch replaces symtab_node with toplevel_node in lto_symtab_encoder and modifies all places where lto_symtab_encoder is used to handle (ignore) asm_node.
gcc/ChangeLog: * ipa-icf.cc (sem_item_optimizer::write_summary): Use toplevel_node. (sem_item_optimizer::read_section): Likewise. * ipa-modref.cc (modref_write): Likewise. * ipa-prop.cc (ipa_write_return_summaries): Likewise. (ipcp_write_transformation_summaries): Likewise. * ipa-reference.cc (ipa_reference_write_optimization_summary): Likewise. * lto-cgraph.cc (lto_symtab_encoder_new): Likewise. (lto_symtab_encoder_encode): Likewise. (lto_symtab_encoder_delete_node): Likewise. (lto_symtab_encoder_in_partition_p): Likewise. (lto_set_symtab_encoder_in_partition): Likewise. (output_refs): Likewise. (compute_ltrans_boundary): Likewise. (output_symtab): Likewise. (output_cgraph_opt_summary): Likewise. * lto-streamer-out.cc (lto_output): Likewise. (produce_symtab): Likewise. (produce_symtab_extension): Likewise. * lto-streamer.h (struct lto_encoder_entry): Likewise. (struct lto_symtab_encoder_d): Likewise. (lto_symtab_encoder_encode): Likewise. (lto_symtab_encoder_delete_node): Likewise. (lto_symtab_encoder_in_partition_p): Likewise. (lto_symtab_encoder_lookup): Likewise. (lsei_next): Likewise. (lsei_varpool_node): Likewise. gcc/lto/ChangeLog: * lto-partition.cc (add_symbol_to_partition): Use toplevel_node. (undo_partition): Likewise. (join_partitions): Likewise. (split_partition_into_nodes): Likewise. (is_partition_reorder): Likewise. (lto_balanced_map): Likewise. (lto_promote_cross_file_statics): Likewise. * lto.cc (lto_wpa_write_files): Likewise. --- gcc/ipa-icf.cc | 21 ++++++------ gcc/ipa-modref.cc | 8 ++--- gcc/ipa-prop.cc | 16 ++++----- gcc/ipa-reference.cc | 14 ++++---- gcc/lto-cgraph.cc | 40 ++++++++++++++-------- gcc/lto-streamer-out.cc | 30 ++++++++++++----- gcc/lto-streamer.h | 20 +++++------ gcc/lto/lto-partition.cc | 72 +++++++++++++++++++++++++--------------- gcc/lto/lto.cc | 9 +++-- 9 files changed, 140 insertions(+), 90 deletions(-) diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc index b354fb1e704..c7596f9ff1c 100644 --- a/gcc/ipa-icf.cc +++ b/gcc/ipa-icf.cc @@ -2166,7 +2166,9 @@ sem_item_optimizer::write_summary (void) !lsei_end_p (lsei); lsei_next_in_partition (&lsei)) { - symtab_node *node = lsei_node (lsei); + symtab_node *node = dyn_cast <symtab_node *> (lsei_node (lsei)); + if (!node) + continue; if (m_symtab_node_map.get (node)) count++; @@ -2179,7 +2181,9 @@ sem_item_optimizer::write_summary (void) !lsei_end_p (lsei); lsei_next_in_partition (&lsei)) { - symtab_node *node = lsei_node (lsei); + symtab_node *node = dyn_cast <symtab_node *> (lsei_node (lsei)); + if (!node) + continue; sem_item **item = m_symtab_node_map.get (node); @@ -2233,7 +2237,7 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data, for (i = 0; i < count; i++) { unsigned int index; - symtab_node *node; + toplevel_node *node; lto_symtab_encoder_t encoder; index = streamer_read_uhwi (&ib_main); @@ -2241,12 +2245,11 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data, node = lto_symtab_encoder_deref (encoder, index); hashval_t hash = streamer_read_uhwi (&ib_main); - gcc_assert (node->definition); + if (symtab_node *snode = dyn_cast <symtab_node *> (node)) + gcc_assert (snode->definition); - if (is_a<cgraph_node *> (node)) + if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node)) { - cgraph_node *cnode = dyn_cast <cgraph_node *> (node); - sem_function *fn = new sem_function (cnode, &m_bmstack); unsigned count = streamer_read_uhwi (&ib_main); inchash::hash hstate (0); @@ -2263,10 +2266,8 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data, fn->set_hash (hash); m_items.safe_push (fn); } - else + else if (varpool_node *vnode = dyn_cast <varpool_node *> (node)) { - varpool_node *vnode = dyn_cast <varpool_node *> (node); - sem_variable *var = new sem_variable (vnode, &m_bmstack); var->set_hash (hash); m_items.safe_push (var); diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc index d3e510195b5..a319ee35b3b 100644 --- a/gcc/ipa-modref.cc +++ b/gcc/ipa-modref.cc @@ -3752,8 +3752,8 @@ modref_write () for (i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + cgraph_node *cnode = dyn_cast <cgraph_node *> (tnode); modref_summary_lto *r; if (cnode && cnode->definition && !cnode->alias @@ -3765,8 +3765,8 @@ modref_write () for (i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + cgraph_node *cnode = dyn_cast <cgraph_node *> (tnode); if (cnode && cnode->definition && !cnode->alias) { diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 84d4fb5db67..17662ca027f 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -5482,8 +5482,8 @@ ipa_write_return_summaries (output_block *ob) unsigned int count = 0; for (int i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + cgraph_node *cnode = dyn_cast <cgraph_node *> (tnode); ipa_return_value_summary *v; if (cnode && cnode->definition && !cnode->alias @@ -5495,8 +5495,8 @@ ipa_write_return_summaries (output_block *ob) for (int i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + cgraph_node *cnode = dyn_cast <cgraph_node *> (tnode); ipa_return_value_summary *v; if (cnode && cnode->definition && !cnode->alias @@ -5771,8 +5771,8 @@ ipcp_write_transformation_summaries (void) for (int i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + cgraph_node *cnode = dyn_cast <cgraph_node *> (tnode); if (!cnode) continue; ipcp_transformation *ts = ipcp_get_transformation_summary (cnode); @@ -5785,8 +5785,8 @@ ipcp_write_transformation_summaries (void) for (int i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + cgraph_node *cnode = dyn_cast <cgraph_node *> (tnode); if (!cnode) continue; ipcp_transformation *ts = ipcp_get_transformation_summary (cnode); diff --git a/gcc/ipa-reference.cc b/gcc/ipa-reference.cc index 975341c9f6f..173c7a59dd2 100644 --- a/gcc/ipa-reference.cc +++ b/gcc/ipa-reference.cc @@ -1070,8 +1070,8 @@ ipa_reference_write_optimization_summary (void) /* See what variables we are interested in. */ for (i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - varpool_node *vnode = dyn_cast <varpool_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + varpool_node *vnode = dyn_cast <varpool_node *> (tnode); int id; if (vnode @@ -1089,8 +1089,8 @@ ipa_reference_write_optimization_summary (void) if (ltrans_statics_bitcount) for (i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + cgraph_node *cnode = dyn_cast <cgraph_node *> (tnode); if (cnode && write_node_summary_p (cnode, encoder, ltrans_statics)) count++; } @@ -1104,15 +1104,15 @@ ipa_reference_write_optimization_summary (void) if (ltrans_statics_bitcount) for (i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + cgraph_node *cnode = dyn_cast <cgraph_node *> (tnode); if (cnode && write_node_summary_p (cnode, encoder, ltrans_statics)) { ipa_reference_optimization_summary_t info; int node_ref; info = get_reference_optimization_summary (cnode); - node_ref = lto_symtab_encoder_encode (encoder, snode); + node_ref = lto_symtab_encoder_encode (encoder, tnode); streamer_write_uhwi_stream (ob->main_stream, node_ref); stream_out_bitmap (ob, info->statics_read, ltrans_statics, diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc index 0af2e889af8..d6e58351ce4 100644 --- a/gcc/lto-cgraph.cc +++ b/gcc/lto-cgraph.cc @@ -82,7 +82,7 @@ lto_symtab_encoder_new (bool for_input) lto_symtab_encoder_t encoder = XCNEW (struct lto_symtab_encoder_d); if (!for_input) - encoder->map = new hash_map<symtab_node *, size_t>; + encoder->map = new hash_map<toplevel_node *, size_t>; encoder->nodes.create (0); return encoder; } @@ -108,7 +108,7 @@ lto_symtab_encoder_delete (lto_symtab_encoder_t encoder) int lto_symtab_encoder_encode (lto_symtab_encoder_t encoder, - symtab_node *node) + toplevel_node *node) { int ref; @@ -140,7 +140,7 @@ lto_symtab_encoder_encode (lto_symtab_encoder_t encoder, bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t encoder, - symtab_node *node) + toplevel_node *node) { int index; @@ -214,7 +214,7 @@ lto_set_symtab_encoder_encode_initializer (lto_symtab_encoder_t encoder, bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder, - symtab_node *node) + toplevel_node *node) { int index = lto_symtab_encoder_lookup (encoder, node); if (index == LCC_NOT_FOUND) @@ -226,11 +226,16 @@ lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder, void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder, - symtab_node *node) + toplevel_node *node) { int index = lto_symtab_encoder_encode (encoder, node); if (dump_file) - fprintf(dump_file, "Node %s, index %d\n", node->asm_name(), index); + { + if (symtab_node* snode = dyn_cast<symtab_node*> (node)) + fprintf (dump_file, "Node %s, index %d\n", snode->asm_name (), index); + else + fprintf (dump_file, "Asm node, index %d\n", index); + } encoder->nodes[index].in_partition = true; } @@ -767,7 +772,10 @@ output_refs (lto_symtab_encoder_t encoder) for (int i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *node = lto_symtab_encoder_deref (encoder, i); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + symtab_node *node = dyn_cast <symtab_node *> (tnode); + if (!node) + continue; /* IPA_REF_ALIAS references are always preserved in the boundary. Alias node can't have other references and @@ -892,7 +900,7 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) pickle those too. */ for (i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *node = lto_symtab_encoder_deref (encoder, i); + toplevel_node *node = lto_symtab_encoder_deref (encoder, i); if (varpool_node *vnode = dyn_cast <varpool_node *> (node)) { if (!lto_symtab_encoder_encode_initializer_p (encoder, @@ -959,7 +967,11 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) to stay to aid local calling conventions. */ for (i = 0; i < lto_symtab_encoder_size (encoder); i++) { - symtab_node *node = lto_symtab_encoder_deref (encoder, i); + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + symtab_node *node = dyn_cast <symtab_node *> (tnode); + if (!node) + continue; + cgraph_node *cnode = dyn_cast <cgraph_node *> (node); if (node->alias && node->analyzed) @@ -1009,11 +1021,11 @@ output_symtab (void) n_nodes = lto_symtab_encoder_size (encoder); for (i = 0; i < n_nodes; i++) { - symtab_node *node = lto_symtab_encoder_deref (encoder, i); + toplevel_node *node = lto_symtab_encoder_deref (encoder, i); if (cgraph_node *cnode = dyn_cast <cgraph_node *> (node)) lto_output_node (ob, cnode, encoder); - else - lto_output_varpool_node (ob, dyn_cast<varpool_node *> (node), encoder); + else if (varpool_node *vnode = dyn_cast <varpool_node *> (node)) + lto_output_varpool_node (ob, vnode, encoder); } /* Go over the nodes in SET again to write edges. */ @@ -2105,7 +2117,7 @@ output_cgraph_opt_summary (void) n_nodes = lto_symtab_encoder_size (encoder); for (i = 0; i < n_nodes; i++) { - symtab_node *node = lto_symtab_encoder_deref (encoder, i); + toplevel_node *node = lto_symtab_encoder_deref (encoder, i); cgraph_node *cnode = dyn_cast <cgraph_node *> (node); if (cnode && output_cgraph_opt_summary_p (cnode)) count++; @@ -2113,7 +2125,7 @@ output_cgraph_opt_summary (void) streamer_write_uhwi (ob, count); for (i = 0; i < n_nodes; i++) { - symtab_node *node = lto_symtab_encoder_deref (encoder, i); + toplevel_node *node = lto_symtab_encoder_deref (encoder, i); cgraph_node *cnode = dyn_cast <cgraph_node *> (node); if (cnode && output_cgraph_opt_summary_p (cnode)) { diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc index 308ab3416b3..e5de8d80cf4 100644 --- a/gcc/lto-streamer-out.cc +++ b/gcc/lto-streamer-out.cc @@ -2851,16 +2851,18 @@ lto_output (void) section copying. */ for (i = 0; i < n_nodes; i++) { - symtab_node *snode = lto_symtab_encoder_deref (encoder, i); - if (snode->alias) + toplevel_node *tnode = lto_symtab_encoder_deref (encoder, i); + symtab_node *node = dyn_cast <symtab_node *> (tnode); + if (!node || node->alias) continue; - if (cgraph_node *node = dyn_cast <cgraph_node *> (snode)) + + if (cgraph_node *node = dyn_cast <cgraph_node *> (tnode)) { if (lto_symtab_encoder_encode_body_p (encoder, node) && !node->clone_of) symbols_to_copy.safe_push (node); } - else if (varpool_node *node = dyn_cast <varpool_node *> (snode)) + else if (varpool_node *node = dyn_cast <varpool_node *> (tnode)) { /* Wrap symbol references inside the ctor in a type preserving MEM_REF. */ @@ -3202,7 +3204,10 @@ produce_symtab (struct output_block *ob) for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); + toplevel_node *tnode = lsei_node (lsei); + symtab_node *node = dyn_cast<symtab_node*> (tnode); + if (!node) + continue; if (DECL_EXTERNAL (node->decl) || !node->output_to_lto_symbol_table_p ()) continue; @@ -3212,7 +3217,10 @@ produce_symtab (struct output_block *ob) for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); + toplevel_node *tnode = lsei_node (lsei); + symtab_node *node = dyn_cast<symtab_node*> (tnode); + if (!node) + continue; if (!DECL_EXTERNAL (node->decl) || !node->output_to_lto_symbol_table_p ()) continue; @@ -3253,7 +3261,10 @@ produce_symtab_extension (struct output_block *ob, for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); + toplevel_node *tnode = lsei_node (lsei); + symtab_node *node = dyn_cast<symtab_node*> (tnode); + if (!node) + continue; if (DECL_EXTERNAL (node->decl) || !node->output_to_lto_symbol_table_p ()) continue; @@ -3263,7 +3274,10 @@ produce_symtab_extension (struct output_block *ob, for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); + toplevel_node *tnode = lsei_node (lsei); + symtab_node *node = dyn_cast<symtab_node*> (tnode); + if (!node) + continue; if (!DECL_EXTERNAL (node->decl) || !node->output_to_lto_symbol_table_p ()) continue; diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 4b7209e3d82..a1ec3b67b2f 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -444,12 +444,12 @@ struct lto_stats_d struct lto_encoder_entry { /* Constructor. */ - lto_encoder_entry (symtab_node* n) + lto_encoder_entry (toplevel_node* n) : node (n), in_partition (false), body (false), only_for_inlining (true), initializer (false) {} - symtab_node *node; + toplevel_node *node; /* Is the node in this partition (i.e. ltrans of this partition will be responsible for outputting it)? */ unsigned int in_partition:1; @@ -468,7 +468,7 @@ struct lto_encoder_entry struct lto_symtab_encoder_d { vec<lto_encoder_entry> nodes; - hash_map<symtab_node *, size_t> *map; + hash_map<toplevel_node *, size_t> *map; /* Mapping of input order of nodes onto output order. */ hash_map<int_hash<int, -1, -2>, int> *order_remap; @@ -918,17 +918,17 @@ void lto_prepare_function_for_streaming (cgraph_node *); /* In lto-cgraph.cc */ extern bool asm_nodes_output; lto_symtab_encoder_t lto_symtab_encoder_new (bool); -int lto_symtab_encoder_encode (lto_symtab_encoder_t, symtab_node *); +int lto_symtab_encoder_encode (lto_symtab_encoder_t, toplevel_node *); void lto_symtab_encoder_delete (lto_symtab_encoder_t); -bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t, symtab_node *); +bool lto_symtab_encoder_delete_node (lto_symtab_encoder_t, toplevel_node *); bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t, struct cgraph_node *); bool lto_symtab_encoder_only_for_inlining_p (lto_symtab_encoder_t, struct cgraph_node *); bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t, - symtab_node *); + toplevel_node *); void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t, - symtab_node *); + toplevel_node *); bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t, varpool_node *); @@ -1104,7 +1104,7 @@ lto_symtab_encoder_size (lto_symtab_encoder_t encoder) inline int lto_symtab_encoder_lookup (lto_symtab_encoder_t encoder, - symtab_node *node) + toplevel_node *node) { size_t *slot = encoder->map->get (node); return (slot && *slot ? *(slot) - 1 : LCC_NOT_FOUND); @@ -1125,7 +1125,7 @@ lsei_next (lto_symtab_encoder_iterator *lsei) } /* Return the node pointed to by LSI. */ -inline symtab_node * +inline toplevel_node * lsei_node (lto_symtab_encoder_iterator lsei) { return lsei.encoder->nodes[lsei.index].node; @@ -1147,7 +1147,7 @@ lsei_varpool_node (lto_symtab_encoder_iterator lsei) /* Return the cgraph node corresponding to REF using ENCODER. */ -inline symtab_node * +inline toplevel_node * lto_symtab_encoder_deref (lto_symtab_encoder_t encoder, int ref) { if (ref == LCC_NOT_FOUND) diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc index 650bf638162..a9d7dbb48e9 100644 --- a/gcc/lto/lto-partition.cc +++ b/gcc/lto/lto-partition.cc @@ -43,7 +43,8 @@ along with GCC; see the file COPYING3. If not see vec<ltrans_partition> ltrans_partitions; -static void add_symbol_to_partition (ltrans_partition part, symtab_node *node); +static void add_symbol_to_partition (ltrans_partition part, + toplevel_node *node); /* Helper for qsort; compare partitions and return one with smaller order. */ @@ -266,9 +267,15 @@ contained_in_symbol (symtab_node *node) of other symbol definition, add the other symbol, too. */ static void -add_symbol_to_partition (ltrans_partition part, symtab_node *node) +add_symbol_to_partition (ltrans_partition part, toplevel_node *tnode) { symtab_node *node1; + symtab_node* node = dyn_cast <symtab_node*> (tnode); + if (!node) + { + lto_set_symtab_encoder_in_partition (part->encoder, tnode); + return; + } /* Verify that we do not try to duplicate something that cannot be. */ gcc_checking_assert (node->get_partitioning_class () == SYMBOL_DUPLICATE @@ -299,21 +306,25 @@ undo_partition (ltrans_partition partition, unsigned int n_nodes) { while (lto_symtab_encoder_size (partition->encoder) > (int)n_nodes) { - symtab_node *node = lto_symtab_encoder_deref (partition->encoder, - n_nodes); - partition->symbols--; - cgraph_node *cnode; + toplevel_node *tnode = lto_symtab_encoder_deref (partition->encoder, + n_nodes); /* After UNDO we no longer know what was visited. */ if (partition->initializers_visited) delete partition->initializers_visited; partition->initializers_visited = NULL; - if (!node->alias && (cnode = dyn_cast <cgraph_node *> (node)) - && node->get_partitioning_class () == SYMBOL_PARTITION) - partition->insns -= ipa_size_summaries->get (cnode)->size; - lto_symtab_encoder_delete_node (partition->encoder, node); - node->aux = (void *)((size_t)node->aux - 1); + lto_symtab_encoder_delete_node (partition->encoder, tnode); + + if (symtab_node* node = dyn_cast <symtab_node *> (tnode)) + { + partition->symbols--; + cgraph_node *cnode; + if (!node->alias && (cnode = dyn_cast <cgraph_node *> (node)) + && node->get_partitioning_class () == SYMBOL_PARTITION) + partition->insns -= ipa_size_summaries->get (cnode)->size; + node->aux = (void *)((size_t)node->aux - 1); + } } } @@ -467,16 +478,17 @@ join_partitions (ltrans_partition into, ltrans_partition from) before adding any symbols to other partition. */ for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); - node->aux = (void *)((size_t)node->aux - 1); + if (symtab_node *node = dyn_cast <symtab_node*> (lsei_node (lsei))) + node->aux = (void *)((size_t)node->aux - 1); } for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); + toplevel_node *node = lsei_node (lsei); - if (symbol_partitioned_p (node)) - continue; + if (symtab_node *snode = dyn_cast <symtab_node*> (node)) + if (symbol_partitioned_p (snode)) + continue; add_symbol_to_partition (into, node); } @@ -498,16 +510,17 @@ split_partition_into_nodes (ltrans_partition part) for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); - node->aux = (void *)((size_t)node->aux - 1); + if (symtab_node *node = dyn_cast <symtab_node*> (lsei_node (lsei))) + node->aux = (void *)((size_t)node->aux - 1); } for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); + toplevel_node *node = lsei_node (lsei); - if (node->get_partitioning_class () != SYMBOL_PARTITION - || symbol_partitioned_p (node)) + symtab_node *snode = dyn_cast <symtab_node*> (node); + if (snode->get_partitioning_class () != SYMBOL_PARTITION + || symbol_partitioned_p (snode)) continue; ltrans_partition new_part = new_partition_no_push (part->name); @@ -527,8 +540,8 @@ is_partition_reorder (ltrans_partition part) for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); - if (node->no_reorder) + symtab_node *node = dyn_cast <symtab_node*> (lsei_node (lsei)); + if (!node || node->no_reorder) return false; } return true; @@ -1172,8 +1185,12 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size) { int j; struct ipa_ref *ref = NULL; - symtab_node *snode = lto_symtab_encoder_deref (partition->encoder, - last_visited_node); + toplevel_node *tnode = lto_symtab_encoder_deref (partition->encoder, + last_visited_node); + + symtab_node* snode = dyn_cast <symtab_node*> (tnode); + if (!snode) + continue; if (cgraph_node *node = dyn_cast <cgraph_node *> (snode)) { @@ -1862,7 +1879,10 @@ lto_promote_cross_file_statics (void) for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); + toplevel_node *tnode = lsei_node (lsei); + symtab_node *node = dyn_cast <symtab_node*> (tnode); + if (!node) + continue; /* If symbol is static, rename it if its assembler name clashes with anything else in this unit. */ diff --git a/gcc/lto/lto.cc b/gcc/lto/lto.cc index 183634f2abf..7935b1d1cd8 100644 --- a/gcc/lto/lto.cc +++ b/gcc/lto/lto.cc @@ -381,14 +381,17 @@ lto_wpa_write_files (void) !lsei_end_p (lsei); lsei_next_in_partition (&lsei)) { - symtab_node *node = lsei_node (lsei); - fprintf (symtab->dump_file, "%s ", node->dump_asm_name ()); + symtab_node *node = dyn_cast<symtab_node*> (lsei_node (lsei)); + if (node) + fprintf (symtab->dump_file, "%s ", node->dump_asm_name ()); } fprintf (symtab->dump_file, "\n Symbols in boundary: "); for (lsei = lsei_start (part->encoder); !lsei_end_p (lsei); lsei_next (&lsei)) { - symtab_node *node = lsei_node (lsei); + symtab_node *node = dyn_cast<symtab_node*> (lsei_node (lsei)); + if (!node) + continue; if (!lto_symtab_encoder_in_partition_p (part->encoder, node)) { fprintf (symtab->dump_file, "%s ", node->dump_asm_name ()); -- 2.50.0