diff options
Diffstat (limited to 'gcc/lto-cgraph.c')
-rw-r--r-- | gcc/lto-cgraph.c | 108 |
1 files changed, 51 insertions, 57 deletions
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index b52a8e3a55c..427362230df 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -48,7 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" static void output_cgraph_opt_summary (void); -static void input_cgraph_opt_summary (VEC (symtab_node, heap) * nodes); +static void input_cgraph_opt_summary (vec<symtab_node> nodes); /* Number of LDPR values known to GCC. */ #define LDPR_NUM_KNOWN (LDPR_PREVAILING_DEF_IRONLY_EXP + 1) @@ -84,7 +84,7 @@ lto_symtab_encoder_new (bool for_input) if (!for_input) encoder->map = pointer_map_create (); - encoder->nodes = NULL; + encoder->nodes.create (0); return encoder; } @@ -94,7 +94,7 @@ lto_symtab_encoder_new (bool for_input) void lto_symtab_encoder_delete (lto_symtab_encoder_t encoder) { - VEC_free (lto_encoder_entry, heap, encoder->nodes); + encoder->nodes.release (); if (encoder->map) pointer_map_destroy (encoder->map); free (encoder); @@ -116,8 +116,8 @@ lto_symtab_encoder_encode (lto_symtab_encoder_t encoder, { lto_encoder_entry entry = {node, false, false, false}; - ref = VEC_length (lto_encoder_entry, encoder->nodes); - VEC_safe_push (lto_encoder_entry, heap, encoder->nodes, entry); + ref = encoder->nodes.length (); + encoder->nodes.safe_push (entry); return ref; } @@ -125,11 +125,11 @@ lto_symtab_encoder_encode (lto_symtab_encoder_t encoder, if (!slot || !*slot) { lto_encoder_entry entry = {node, false, false, false}; - ref = VEC_length (lto_encoder_entry, encoder->nodes); + ref = encoder->nodes.length (); if (!slot) slot = pointer_map_insert (encoder->map, node); *slot = (void *) (intptr_t) (ref + 1); - VEC_safe_push (lto_encoder_entry, heap, encoder->nodes, entry); + encoder->nodes.safe_push (entry); } else ref = (size_t) *slot - 1; @@ -152,13 +152,11 @@ lto_symtab_encoder_delete_node (lto_symtab_encoder_t encoder, return false; index = (size_t) *slot - 1; - gcc_checking_assert (VEC_index (lto_encoder_entry, - encoder->nodes, index).node - == node); + gcc_checking_assert (encoder->nodes[index].node == node); /* Remove from vector. We do this by swapping node with the last element of the vector. */ - last_node = VEC_pop (lto_encoder_entry, encoder->nodes); + last_node = encoder->nodes.pop (); if (last_node.node != node) { last_slot = pointer_map_contains (encoder->map, last_node.node); @@ -166,8 +164,7 @@ lto_symtab_encoder_delete_node (lto_symtab_encoder_t encoder, *last_slot = (void *)(size_t) (index + 1); /* Move the last element to the original spot of NODE. */ - VEC_replace (lto_encoder_entry, encoder->nodes, index, - last_node); + encoder->nodes[index] = last_node; } /* Remove element from hash table. */ @@ -183,7 +180,7 @@ lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t encoder, struct cgraph_node *node) { int index = lto_symtab_encoder_lookup (encoder, (symtab_node)node); - return VEC_index (lto_encoder_entry, encoder->nodes, index).body; + return encoder->nodes[index].body; } /* Return TRUE if we should encode body of NODE (if any). */ @@ -193,9 +190,8 @@ lto_set_symtab_encoder_encode_body (lto_symtab_encoder_t encoder, struct cgraph_node *node) { int index = lto_symtab_encoder_encode (encoder, (symtab_node)node); - gcc_checking_assert (VEC_index (lto_encoder_entry, encoder->nodes, - index).node == (symtab_node)node); - VEC_index (lto_encoder_entry, encoder->nodes, index).body = true; + gcc_checking_assert (encoder->nodes[index].node == (symtab_node)node); + encoder->nodes[index].body = true; } /* Return TRUE if we should encode initializer of NODE (if any). */ @@ -207,7 +203,7 @@ lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t encoder, int index = lto_symtab_encoder_lookup (encoder, (symtab_node)node); if (index == LCC_NOT_FOUND) return false; - return VEC_index (lto_encoder_entry, encoder->nodes, index).initializer; + return encoder->nodes[index].initializer; } /* Return TRUE if we should encode initializer of NODE (if any). */ @@ -217,7 +213,7 @@ lto_set_symtab_encoder_encode_initializer (lto_symtab_encoder_t encoder, struct varpool_node *node) { int index = lto_symtab_encoder_lookup (encoder, (symtab_node)node); - VEC_index (lto_encoder_entry, encoder->nodes, index).initializer = true; + encoder->nodes[index].initializer = true; } /* Return TRUE if we should encode initializer of NODE (if any). */ @@ -229,7 +225,7 @@ lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder, int index = lto_symtab_encoder_lookup (encoder, (symtab_node)node); if (index == LCC_NOT_FOUND) return false; - return VEC_index (lto_encoder_entry, encoder->nodes, index).in_partition; + return encoder->nodes[index].in_partition; } /* Return TRUE if we should encode body of NODE (if any). */ @@ -239,7 +235,7 @@ lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder, symtab_node node) { int index = lto_symtab_encoder_encode (encoder, (symtab_node)node); - VEC_index (lto_encoder_entry, encoder->nodes, index).in_partition = true; + encoder->nodes[index].in_partition = true; } /* Output the cgraph EDGE to OB using ENCODER. */ @@ -436,9 +432,8 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, streamer_write_hwi_stream (ob->main_stream, node->count_materialization_scale); streamer_write_hwi_stream (ob->main_stream, - VEC_length (ipa_opt_pass, - node->ipa_transforms_to_apply)); - FOR_EACH_VEC_ELT (ipa_opt_pass, node->ipa_transforms_to_apply, i, pass) + node->ipa_transforms_to_apply.length ()); + FOR_EACH_VEC_ELT (node->ipa_transforms_to_apply, i, pass) streamer_write_hwi_stream (ob->main_stream, pass->pass.static_pass_number); if (tag == LTO_symtab_analyzed_node) @@ -897,7 +892,7 @@ static struct cgraph_node * input_node (struct lto_file_decl_data *file_data, struct lto_input_block *ib, enum LTO_symtab_tags tag, - VEC(symtab_node, heap) *nodes) + vec<symtab_node> nodes) { tree fn_decl; struct cgraph_node *node; @@ -916,8 +911,9 @@ input_node (struct lto_file_decl_data *file_data, if (clone_ref != LCC_NOT_FOUND) { - node = cgraph_clone_node (cgraph (VEC_index (symtab_node, nodes, clone_ref)), fn_decl, - 0, CGRAPH_FREQ_BASE, false, NULL, false); + node = cgraph_clone_node (cgraph (nodes[clone_ref]), fn_decl, + 0, CGRAPH_FREQ_BASE, false, + vNULL, false); } else node = cgraph_get_create_node (fn_decl); @@ -930,7 +926,7 @@ input_node (struct lto_file_decl_data *file_data, node->count_materialization_scale = streamer_read_hwi (ib); count = streamer_read_hwi (ib); - node->ipa_transforms_to_apply = NULL; + node->ipa_transforms_to_apply = vNULL; for (i = 0; i < count; i++) { struct opt_pass *pass; @@ -938,8 +934,7 @@ input_node (struct lto_file_decl_data *file_data, gcc_assert (pid < passes_by_id_size); pass = passes_by_id[pid]; - VEC_safe_push (ipa_opt_pass, heap, node->ipa_transforms_to_apply, - (struct ipa_opt_pass_d *) pass); + node->ipa_transforms_to_apply.safe_push ((struct ipa_opt_pass_d *) pass); } if (tag == LTO_symtab_analyzed_node) @@ -1045,7 +1040,7 @@ input_varpool_node (struct lto_file_decl_data *file_data, static void input_ref (struct lto_input_block *ib, symtab_node referring_node, - VEC(symtab_node, heap) *nodes) + vec<symtab_node> nodes) { symtab_node node = NULL; struct bitpack_d bp; @@ -1053,7 +1048,7 @@ input_ref (struct lto_input_block *ib, bp = streamer_read_bitpack (ib); use = (enum ipa_ref_use) bp_unpack_value (&bp, 2); - node = VEC_index (symtab_node, nodes, streamer_read_hwi (ib)); + node = nodes[streamer_read_hwi (ib)]; ipa_record_reference (referring_node, node, use, NULL); } @@ -1063,7 +1058,7 @@ input_ref (struct lto_input_block *ib, indirect_unknown_callee set). */ static void -input_edge (struct lto_input_block *ib, VEC(symtab_node, heap) *nodes, +input_edge (struct lto_input_block *ib, vec<symtab_node> nodes, bool indirect) { struct cgraph_node *caller, *callee; @@ -1075,13 +1070,13 @@ input_edge (struct lto_input_block *ib, VEC(symtab_node, heap) *nodes, struct bitpack_d bp; int ecf_flags = 0; - caller = cgraph (VEC_index (symtab_node, nodes, streamer_read_hwi (ib))); + caller = cgraph (nodes[streamer_read_hwi (ib)]); if (caller == NULL || caller->symbol.decl == NULL_TREE) internal_error ("bytecode stream: no caller found while reading edge"); if (!indirect) { - callee = cgraph (VEC_index (symtab_node, nodes, streamer_read_hwi (ib))); + callee = cgraph (nodes[streamer_read_hwi (ib)]); if (callee == NULL || callee->symbol.decl == NULL_TREE) internal_error ("bytecode stream: no callee found while reading edge"); } @@ -1126,12 +1121,12 @@ input_edge (struct lto_input_block *ib, VEC(symtab_node, heap) *nodes, /* Read a cgraph from IB using the info in FILE_DATA. */ -static VEC(symtab_node, heap) * +static vec<symtab_node> input_cgraph_1 (struct lto_file_decl_data *file_data, struct lto_input_block *ib) { enum LTO_symtab_tags tag; - VEC(symtab_node, heap) *nodes = NULL; + vec<symtab_node> nodes = vNULL; symtab_node node; unsigned i; @@ -1146,7 +1141,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, else if (tag == LTO_symtab_variable) { node = (symtab_node)input_varpool_node (file_data, ib); - VEC_safe_push (symtab_node, heap, nodes, node); + nodes.safe_push (node); lto_symtab_encoder_encode (file_data->symtab_node_encoder, node); } else @@ -1154,7 +1149,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, node = (symtab_node)input_node (file_data, ib, tag, nodes); if (node == NULL || node->symbol.decl == NULL_TREE) internal_error ("bytecode stream: found empty cgraph node"); - VEC_safe_push (symtab_node, heap, nodes, node); + nodes.safe_push (node); lto_symtab_encoder_encode (file_data->symtab_node_encoder, node); } @@ -1165,10 +1160,10 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, /* AUX pointers should be all non-zero for function nodes read from the stream. */ #ifdef ENABLE_CHECKING - FOR_EACH_VEC_ELT (symtab_node, nodes, i, node) + FOR_EACH_VEC_ELT (nodes, i, node) gcc_assert (node->symbol.aux || !is_a <cgraph_node> (node)); #endif - FOR_EACH_VEC_ELT (symtab_node, nodes, i, node) + FOR_EACH_VEC_ELT (nodes, i, node) { int ref; if (cgraph_node *cnode = dyn_cast <cgraph_node> (node)) @@ -1182,7 +1177,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, /* Fixup inlined_to from reference to pointer. */ if (ref != LCC_NOT_FOUND) - cnode->global.inlined_to = cgraph (VEC_index (symtab_node, nodes, ref)); + cgraph (node)->global.inlined_to = cgraph (nodes[ref]); else cnode->global.inlined_to = NULL; } @@ -1191,11 +1186,11 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, /* Fixup same_comdat_group from reference to pointer. */ if (ref != LCC_NOT_FOUND) - node->symbol.same_comdat_group = VEC_index (symtab_node, nodes, ref); + node->symbol.same_comdat_group = nodes[ref]; else node->symbol.same_comdat_group = NULL; } - FOR_EACH_VEC_ELT (symtab_node, nodes, i, node) + FOR_EACH_VEC_ELT (nodes, i, node) node->symbol.aux = is_a <cgraph_node> (node) ? (void *)1 : NULL; return nodes; } @@ -1204,7 +1199,7 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, static void input_refs (struct lto_input_block *ib, - VEC(symtab_node, heap) *nodes) + vec<symtab_node> nodes) { int count; int idx; @@ -1215,7 +1210,7 @@ input_refs (struct lto_input_block *ib, if (!count) break; idx = streamer_read_uhwi (ib); - node = VEC_index (symtab_node, nodes, idx); + node = nodes[idx]; while (count) { input_ref (ib, node, nodes); @@ -1345,7 +1340,7 @@ input_symtab (void) const char *data; size_t len; struct lto_input_block *ib; - VEC(symtab_node, heap) *nodes; + vec<symtab_node> nodes; ib = lto_create_simple_input_block (file_data, LTO_section_symtab_nodes, &data, &len); @@ -1366,7 +1361,7 @@ input_symtab (void) ib, data, len); if (flag_ltrans) input_cgraph_opt_summary (nodes); - VEC_free (symtab_node, heap, nodes); + nodes.release (); } merge_profile_summaries (file_data_vec); @@ -1433,9 +1428,8 @@ output_node_opt_summary (struct output_block *ob, } else streamer_write_uhwi (ob, 0); - streamer_write_uhwi (ob, VEC_length (ipa_replace_map_p, - node->clone.tree_map)); - FOR_EACH_VEC_ELT (ipa_replace_map_p, node->clone.tree_map, i, map) + streamer_write_uhwi (ob, vec_safe_length (node->clone.tree_map)); + FOR_EACH_VEC_SAFE_ELT (node->clone.tree_map, i, map) { int parm_num; tree parm; @@ -1543,7 +1537,7 @@ input_node_opt_summary (struct cgraph_node *node, { struct ipa_replace_map *map = ggc_alloc_ipa_replace_map (); - VEC_safe_push (ipa_replace_map_p, gc, node->clone.tree_map, map); + vec_safe_push (node->clone.tree_map, map); map->parm_num = streamer_read_uhwi (ib_main); map->old_tree = NULL; map->new_tree = stream_read_tree (ib_main, data_in); @@ -1561,8 +1555,8 @@ input_node_opt_summary (struct cgraph_node *node, static void input_cgraph_opt_section (struct lto_file_decl_data *file_data, - const char *data, size_t len, VEC (symtab_node, - heap) * nodes) + const char *data, size_t len, + vec<symtab_node> nodes) { const struct lto_function_header *header = (const struct lto_function_header *) data; @@ -1579,13 +1573,13 @@ input_cgraph_opt_section (struct lto_file_decl_data *file_data, data_in = lto_data_in_create (file_data, (const char *) data + string_offset, - header->string_size, NULL); + header->string_size, vNULL); count = streamer_read_uhwi (&ib_main); for (i = 0; i < count; i++) { int ref = streamer_read_uhwi (&ib_main); - input_node_opt_summary (cgraph (VEC_index (symtab_node, nodes, ref)), + input_node_opt_summary (cgraph (nodes[ref]), &ib_main, data_in); } lto_free_section_data (file_data, LTO_section_cgraph_opt_sum, NULL, data, @@ -1596,7 +1590,7 @@ input_cgraph_opt_section (struct lto_file_decl_data *file_data, /* Input optimization summary of cgraph. */ static void -input_cgraph_opt_summary (VEC (symtab_node, heap) * nodes) +input_cgraph_opt_summary (vec<symtab_node> nodes) { struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data (); struct lto_file_decl_data *file_data; |