diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-08-11 03:04:35 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-08-11 03:04:35 +0000 |
commit | 70225339fc4e163f336e06ce11e3460caf57a8d6 (patch) | |
tree | 9ecc46e97e1f006538b5fc2f9be799708d6b205c /gcc/lto-cgraph.c | |
parent | e5bf9f49b6d5c55779d26e8f840465ee70152ed5 (diff) | |
download | gcc-70225339fc4e163f336e06ce11e3460caf57a8d6.tar.gz |
* cgraph.h (vector types for symtab_node): Add.
* ipa-reference.c (ipa_reference_write_optimization_summary): Update
for new symtab encoder.
(ipa_reference_read_optimization_summary): Likewise.
* lto-cgraph.c (output_varpool): Remove.
(input_cgraph_opt_summary): Take symtab nodes vector as argument.
(LTO_cgraph_tags): Rename to ...
(LTO_symtab_tags): ... this one; add LTO_symtab_variable.
(lto_cgraph_encoder_new): Rename to ...
(lto_symtab_encoder_new): ... this on.
(lto_cgraph_encoder_encode): Rename to ...
(lto_symtab_encoder_encode): ... this one.
(lto_cgraph_encoder_delete): Rename to ...
(lto_symtab_encoder_delete): ... this one.
(lto_cgraph_encoder_deref): Rename to ...
(lto_symtab_encoder_deref): ... this one.
(lto_cgraph_encoder_encode_body_p): Rename to ...
(lto_symtab_encoder_encode_body_p): ... this one.
(lto_varpool_encoder_new, lto_varpool_encoder_delete,
lto_varpool_encoder_encode, lto_varpool_encoder_lookup,
lto_varpool_encoder_deref): Remove.
(lto_varpool_encoder_encode_initializer_p): Rename to ...
(lto_symtab_encoder_encode_initializer_p): ... this one.
(lto_set_varpool_encoder_encode_initializer): Rename to ...
(lto_set_symtab_encoder_encode_initializer): ... this one.
(lto_output_edge): Update.
(lto_output_node): Update.
(lto_output_varpool_node): Update; stream out LTO_symtab_variable tag.
(lto_output_ref): Drop varpool_encoder; update.
(add_node_to): Update.
(add_references): Update.
(output_outgoing_cgraph_edges): Update.
(output_refs): Update.
(compute_ltrans_boundary): Update.
(output_cgraph): Update; output varpools too.
(input_overwrite_node): Update.
(output_varpool): Remove.
(input_node): Update.
(input_ref): Update.
(input_edge): Update.
(input_cgraph_1): Update; input varpool too; unify fixup code.
(input_varpool_1): Remove.
(input_refs): Update.
(input_cgraph): Update.
(output_node_opt_summary): Update.
(input_cgraph_opt_section): Update.
(input_cgraph_opt_summary): Update.
* ipa-pure-const.c (pure_const_write_summary): Update.
(pure_const_read_summary): Update.
* lto-streamer-out.c (lto_write_tree): Update.
(lto_output): Likewise.
(produce_symtab): Update.
(produce_asm_for_decls): Update.
* ipa-inline-analysis.c (inline_read_section): Update.
(inline_write_summary): Update.
* ipa-prop.c (ipa_write_node_info): Update.
(ipa_prop_read_section): Update.
* lto-streamer.h (lto_cgraph_encoder_d): Rename to ...
(lto_symtab_encoder_d): ... this one; add initializer.
(lto_cgraph_encoder_t): Rename to ...
(lto_symtab_encoder_t): ... this one.
(lto_cgraph_encoder_size): Rename to ...
(lto_symtab_encoder_size): ... this one.
(lto_varpool_encoder_d): ... remove.
(lto_varpool_encoder_t): Remove.
(lto_out_decl_state): Remove cgraph_node_encoder, varpool_node_encoder
add symtab_node_encoder.
(lto_file_decl_data): Likewise.
(lto_cgraph_encoder_deref, lto_cgraph_encoder_lookup,
lto_cgraph_encoder_new, lto_cgraph_encoder_encode, lto_cgraph_encoder_delete,
lto_cgraph_encoder_encode_body_p, lto_varpool_encoder_encode_body_p,
lto_varpool_encoder_deref, lto_varpool_encoder_lookup, lto_varpool_encoder_new,
lto_varpool_encoder_encode, lto_varpool_encoder_delete,
lto_varpool_encoder_encode_initializer_p): Remove.
(lto_symtab_encoder_deref, lto_symtab_encoder_lookup,
lto_symtab_encoder_t, lto_symtab_encoder_encode, lto_symtab_encoder_delete,
lto_symtab_encoder_encode_body_p, lto_symtab_encoder_encode_initializer_p):
New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190309 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lto-cgraph.c')
-rw-r--r-- | gcc/lto-cgraph.c | 518 |
1 files changed, 183 insertions, 335 deletions
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index c349709989d..9ba21e089a5 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -46,9 +46,8 @@ along with GCC; see the file COPYING3. If not see #include "tree-streamer.h" #include "gcov-io.h" -static void output_varpool (cgraph_node_set, varpool_node_set); static void output_cgraph_opt_summary (cgraph_node_set set); -static void input_cgraph_opt_summary (VEC (cgraph_node_ptr, heap) * nodes); +static void input_cgraph_opt_summary (VEC (symtab_node, heap) * nodes); /* Number of LDPR values known to GCC. */ #define LDPR_NUM_KNOWN (LDPR_PREVAILING_DEF_IRONLY_EXP + 1) @@ -58,29 +57,31 @@ static int order_base; /* Cgraph streaming is organized as set of record whose type is indicated by a tag. */ -enum LTO_cgraph_tags +enum LTO_symtab_tags { /* Must leave 0 for the stopper. */ /* Cgraph node without body available. */ - LTO_cgraph_unavail_node = 1, + LTO_symtab_unavail_node = 1, /* Cgraph node with function body. */ - LTO_cgraph_analyzed_node, + LTO_symtab_analyzed_node, /* Cgraph edges. */ - LTO_cgraph_edge, - LTO_cgraph_indirect_edge, - LTO_cgraph_last_tag + LTO_symtab_edge, + LTO_symtab_indirect_edge, + LTO_symtab_variable, + LTO_symtab_last_tag }; -/* Create a new cgraph encoder. */ +/* Create a new symtab encoder. */ -lto_cgraph_encoder_t -lto_cgraph_encoder_new (void) +lto_symtab_encoder_t +lto_symtab_encoder_new (void) { - lto_cgraph_encoder_t encoder = XCNEW (struct lto_cgraph_encoder_d); + lto_symtab_encoder_t encoder = XCNEW (struct lto_symtab_encoder_d); encoder->map = pointer_map_create (); encoder->nodes = NULL; encoder->body = pointer_set_create (); + encoder->initializer = pointer_set_create (); return encoder; } @@ -88,22 +89,23 @@ lto_cgraph_encoder_new (void) /* Delete ENCODER and its components. */ void -lto_cgraph_encoder_delete (lto_cgraph_encoder_t encoder) +lto_symtab_encoder_delete (lto_symtab_encoder_t encoder) { - VEC_free (cgraph_node_ptr, heap, encoder->nodes); + VEC_free (symtab_node, heap, encoder->nodes); pointer_map_destroy (encoder->map); pointer_set_destroy (encoder->body); + pointer_set_destroy (encoder->initializer); free (encoder); } -/* Return the existing reference number of NODE in the cgraph encoder in +/* Return the existing reference number of NODE in the symtab encoder in output block OB. Assign a new reference if this is the first time NODE is encoded. */ int -lto_cgraph_encoder_encode (lto_cgraph_encoder_t encoder, - struct cgraph_node *node) +lto_symtab_encoder_encode (lto_symtab_encoder_t encoder, + symtab_node node) { int ref; void **slot; @@ -111,10 +113,10 @@ lto_cgraph_encoder_encode (lto_cgraph_encoder_t encoder, slot = pointer_map_contains (encoder->map, node); if (!slot) { - ref = VEC_length (cgraph_node_ptr, encoder->nodes); + ref = VEC_length (symtab_node, encoder->nodes); slot = pointer_map_insert (encoder->map, node); *slot = (void *) (intptr_t) ref; - VEC_safe_push (cgraph_node_ptr, heap, encoder->nodes, node); + VEC_safe_push (symtab_node, heap, encoder->nodes, node); } else ref = (int) (intptr_t) *slot; @@ -128,8 +130,8 @@ lto_cgraph_encoder_encode (lto_cgraph_encoder_t encoder, or LCC_NOT_FOUND if it is not there. */ int -lto_cgraph_encoder_lookup (lto_cgraph_encoder_t encoder, - struct cgraph_node *node) +lto_symtab_encoder_lookup (lto_symtab_encoder_t encoder, + symtab_node node) { void **slot = pointer_map_contains (encoder->map, node); return (slot ? (int) (intptr_t) *slot : LCC_NOT_FOUND); @@ -138,20 +140,20 @@ lto_cgraph_encoder_lookup (lto_cgraph_encoder_t encoder, /* Return the cgraph node corresponding to REF using ENCODER. */ -struct cgraph_node * -lto_cgraph_encoder_deref (lto_cgraph_encoder_t encoder, int ref) +symtab_node +lto_symtab_encoder_deref (lto_symtab_encoder_t encoder, int ref) { if (ref == LCC_NOT_FOUND) return NULL; - return VEC_index (cgraph_node_ptr, encoder->nodes, ref); + return VEC_index (symtab_node, encoder->nodes, ref); } /* Return TRUE if we should encode initializer of NODE (if any). */ bool -lto_cgraph_encoder_encode_body_p (lto_cgraph_encoder_t encoder, +lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t encoder, struct cgraph_node *node) { return pointer_set_contains (encoder->body, node); @@ -160,91 +162,17 @@ lto_cgraph_encoder_encode_body_p (lto_cgraph_encoder_t encoder, /* Return TRUE if we should encode body of NODE (if any). */ static void -lto_set_cgraph_encoder_encode_body (lto_cgraph_encoder_t encoder, +lto_set_symtab_encoder_encode_body (lto_symtab_encoder_t encoder, struct cgraph_node *node) { pointer_set_insert (encoder->body, node); } -/* Create a new varpool encoder. */ - -lto_varpool_encoder_t -lto_varpool_encoder_new (void) -{ - lto_varpool_encoder_t encoder = XCNEW (struct lto_varpool_encoder_d); - encoder->map = pointer_map_create (); - encoder->initializer = pointer_set_create (); - encoder->nodes = NULL; - return encoder; -} - - -/* Delete ENCODER and its components. */ - -void -lto_varpool_encoder_delete (lto_varpool_encoder_t encoder) -{ - VEC_free (varpool_node_ptr, heap, encoder->nodes); - pointer_map_destroy (encoder->map); - pointer_set_destroy (encoder->initializer); - free (encoder); -} - - -/* Return the existing reference number of NODE in the varpool encoder in - output block OB. Assign a new reference if this is the first time - NODE is encoded. */ - -int -lto_varpool_encoder_encode (lto_varpool_encoder_t encoder, - struct varpool_node *node) -{ - int ref; - void **slot; - - slot = pointer_map_contains (encoder->map, node); - if (!slot) - { - ref = VEC_length (varpool_node_ptr, encoder->nodes); - slot = pointer_map_insert (encoder->map, node); - *slot = (void *) (intptr_t) ref; - VEC_safe_push (varpool_node_ptr, heap, encoder->nodes, node); - } - else - ref = (int) (intptr_t) *slot; - - return ref; -} - -/* Look up NODE in encoder. Return NODE's reference if it has been encoded - or LCC_NOT_FOUND if it is not there. */ - -int -lto_varpool_encoder_lookup (lto_varpool_encoder_t encoder, - struct varpool_node *node) -{ - void **slot = pointer_map_contains (encoder->map, node); - return (slot ? (int) (intptr_t) *slot : LCC_NOT_FOUND); -} - - -/* Return the varpool node corresponding to REF using ENCODER. */ - -struct varpool_node * -lto_varpool_encoder_deref (lto_varpool_encoder_t encoder, int ref) -{ - if (ref == LCC_NOT_FOUND) - return NULL; - - return VEC_index (varpool_node_ptr, encoder->nodes, ref); -} - - /* Return TRUE if we should encode initializer of NODE (if any). */ bool -lto_varpool_encoder_encode_initializer_p (lto_varpool_encoder_t encoder, - struct varpool_node *node) +lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t encoder, + struct varpool_node *node) { return pointer_set_contains (encoder->initializer, node); } @@ -252,8 +180,8 @@ lto_varpool_encoder_encode_initializer_p (lto_varpool_encoder_t encoder, /* Return TRUE if we should encode initializer of NODE (if any). */ static void -lto_set_varpool_encoder_encode_initializer (lto_varpool_encoder_t encoder, - struct varpool_node *node) +lto_set_symtab_encoder_encode_initializer (lto_symtab_encoder_t encoder, + struct varpool_node *node) { pointer_set_insert (encoder->initializer, node); } @@ -262,26 +190,26 @@ lto_set_varpool_encoder_encode_initializer (lto_varpool_encoder_t encoder, static void lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge, - lto_cgraph_encoder_t encoder) + lto_symtab_encoder_t encoder) { unsigned int uid; intptr_t ref; struct bitpack_d bp; if (edge->indirect_unknown_callee) - streamer_write_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag, - LTO_cgraph_indirect_edge); + streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag, + LTO_symtab_indirect_edge); else - streamer_write_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag, - LTO_cgraph_edge); + streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag, + LTO_symtab_edge); - ref = lto_cgraph_encoder_lookup (encoder, edge->caller); + ref = lto_symtab_encoder_lookup (encoder, (symtab_node)edge->caller); gcc_assert (ref != LCC_NOT_FOUND); streamer_write_hwi_stream (ob->main_stream, ref); if (!edge->indirect_unknown_callee) { - ref = lto_cgraph_encoder_lookup (encoder, edge->callee); + ref = lto_symtab_encoder_lookup (encoder, (symtab_node)edge->callee); gcc_assert (ref != LCC_NOT_FOUND); streamer_write_hwi_stream (ob->main_stream, ref); } @@ -408,7 +336,7 @@ reachable_from_this_partition_p (struct cgraph_node *node, cgraph_node_set set) static void lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, - lto_cgraph_encoder_t encoder, cgraph_node_set set, + lto_symtab_encoder_t encoder, cgraph_node_set set, varpool_node_set vset) { unsigned int tag; @@ -421,11 +349,11 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, boundary_p = !cgraph_node_in_set_p (node, set); if (node->analyzed && !boundary_p) - tag = LTO_cgraph_analyzed_node; + tag = LTO_symtab_analyzed_node; else - tag = LTO_cgraph_unavail_node; + tag = LTO_symtab_unavail_node; - streamer_write_enum (ob->main_stream, LTO_cgraph_tags, LTO_cgraph_last_tag, + streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag, tag); streamer_write_hwi_stream (ob->main_stream, node->symbol.order); @@ -454,13 +382,13 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, clone_of = node->clone_of; while (clone_of - && (ref = lto_cgraph_encoder_lookup (encoder, clone_of)) == LCC_NOT_FOUND) + && (ref = lto_symtab_encoder_lookup (encoder, (symtab_node)clone_of)) == LCC_NOT_FOUND) if (clone_of->prev_sibling_clone) clone_of = clone_of->prev_sibling_clone; else clone_of = clone_of->clone_of; - if (LTO_cgraph_analyzed_node) + if (LTO_symtab_analyzed_node) gcc_assert (clone_of || !node->clone_of); if (!clone_of) streamer_write_hwi_stream (ob->main_stream, LCC_NOT_FOUND); @@ -472,11 +400,11 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, streamer_write_hwi_stream (ob->main_stream, node->count); streamer_write_hwi_stream (ob->main_stream, node->count_materialization_scale); - if (tag == LTO_cgraph_analyzed_node) + if (tag == LTO_symtab_analyzed_node) { if (node->global.inlined_to) { - ref = lto_cgraph_encoder_lookup (encoder, node->global.inlined_to); + ref = lto_symtab_encoder_lookup (encoder, (symtab_node)node->global.inlined_to); gcc_assert (ref != LCC_NOT_FOUND); } else @@ -487,8 +415,8 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, if (node->symbol.same_comdat_group && !boundary_p) { - ref = lto_cgraph_encoder_lookup (encoder, - cgraph (node->symbol.same_comdat_group)); + ref = lto_symtab_encoder_lookup (encoder, + node->symbol.same_comdat_group); gcc_assert (ref != LCC_NOT_FOUND); } else @@ -505,7 +433,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, bp_pack_value (&bp, node->symbol.force_output, 1); bp_pack_value (&bp, node->symbol.address_taken, 1); bp_pack_value (&bp, node->abstract_and_needed, 1); - bp_pack_value (&bp, tag == LTO_cgraph_analyzed_node + bp_pack_value (&bp, tag == LTO_symtab_analyzed_node && !DECL_EXTERNAL (node->symbol.decl) && !DECL_COMDAT (node->symbol.decl) && (reachable_from_other_partition_p (node, set) @@ -554,13 +482,15 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, static void lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node *node, - lto_varpool_encoder_t varpool_encoder, + lto_symtab_encoder_t encoder, cgraph_node_set set, varpool_node_set vset) { bool boundary_p = !varpool_node_in_set_p (node, vset) && node->analyzed; struct bitpack_d bp; int ref; + streamer_write_enum (ob->main_stream, LTO_symtab_tags, LTO_symtab_last_tag, + LTO_symtab_variable); streamer_write_hwi_stream (ob->main_stream, node->symbol.order); lto_output_var_decl_index (ob->decl_state, ob->main_stream, node->symbol.decl); bp = bitpack_create (ob->main_stream); @@ -593,8 +523,8 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node lto_output_var_decl_index (ob->decl_state, ob->main_stream, node->alias_of); if (node->symbol.same_comdat_group && !boundary_p) { - ref = lto_varpool_encoder_lookup (varpool_encoder, - varpool (node->symbol.same_comdat_group)); + ref = lto_symtab_encoder_lookup (encoder, + node->symbol.same_comdat_group); gcc_assert (ref != LCC_NOT_FOUND); } else @@ -609,27 +539,17 @@ lto_output_varpool_node (struct lto_simple_output_block *ob, struct varpool_node static void lto_output_ref (struct lto_simple_output_block *ob, struct ipa_ref *ref, - lto_cgraph_encoder_t encoder, - lto_varpool_encoder_t varpool_encoder) + lto_symtab_encoder_t encoder) { struct bitpack_d bp; + int nref; + bp = bitpack_create (ob->main_stream); - bp_pack_value (&bp, symtab_function_p (ref->referred), 1); bp_pack_value (&bp, ref->use, 2); streamer_write_bitpack (&bp); - if (symtab_function_p (ref->referred)) - { - int nref = lto_cgraph_encoder_lookup (encoder, ipa_ref_node (ref)); - gcc_assert (nref != LCC_NOT_FOUND); - streamer_write_hwi_stream (ob->main_stream, nref); - } - else - { - int nref = lto_varpool_encoder_lookup (varpool_encoder, - ipa_ref_varpool_node (ref)); - gcc_assert (nref != LCC_NOT_FOUND); - streamer_write_hwi_stream (ob->main_stream, nref); - } + nref = lto_symtab_encoder_lookup (encoder, ref->referred); + gcc_assert (nref != LCC_NOT_FOUND); + streamer_write_hwi_stream (ob->main_stream, nref); } /* Stream out profile_summary to OB. */ @@ -654,21 +574,20 @@ output_profile_summary (struct lto_simple_output_block *ob) Do it in a way so clones appear first. */ static void -add_node_to (lto_cgraph_encoder_t encoder, struct cgraph_node *node, +add_node_to (lto_symtab_encoder_t encoder, struct cgraph_node *node, bool include_body) { if (node->clone_of) add_node_to (encoder, node->clone_of, include_body); else if (include_body) - lto_set_cgraph_encoder_encode_body (encoder, node); - lto_cgraph_encoder_encode (encoder, node); + lto_set_symtab_encoder_encode_body (encoder, node); + lto_symtab_encoder_encode (encoder, (symtab_node)node); } /* Add all references in LIST to encoders. */ static void -add_references (lto_cgraph_encoder_t encoder, - lto_varpool_encoder_t varpool_encoder, +add_references (lto_symtab_encoder_t encoder, struct ipa_ref_list *list) { int i; @@ -679,7 +598,7 @@ add_references (lto_cgraph_encoder_t encoder, else { struct varpool_node *vnode = ipa_ref_varpool_node (ref); - lto_varpool_encoder_encode (varpool_encoder, vnode); + lto_symtab_encoder_encode (encoder, (symtab_node)vnode); } } @@ -689,7 +608,7 @@ add_references (lto_cgraph_encoder_t encoder, static void output_outgoing_cgraph_edges (struct cgraph_edge *edge, struct lto_simple_output_block *ob, - lto_cgraph_encoder_t encoder) + lto_symtab_encoder_t encoder) { if (!edge) return; @@ -706,8 +625,7 @@ output_outgoing_cgraph_edges (struct cgraph_edge *edge, static void output_refs (cgraph_node_set set, varpool_node_set vset, - lto_cgraph_encoder_t encoder, - lto_varpool_encoder_t varpool_encoder) + lto_symtab_encoder_t encoder) { cgraph_node_set_iterator csi; varpool_node_set_iterator vsi; @@ -727,10 +645,11 @@ output_refs (cgraph_node_set set, varpool_node_set vset, { streamer_write_uhwi_stream (ob->main_stream, count); streamer_write_uhwi_stream (ob->main_stream, - lto_cgraph_encoder_lookup (encoder, node)); + lto_symtab_encoder_lookup (encoder, + (symtab_node)node)); for (i = 0; ipa_ref_list_reference_iterate (&node->symbol.ref_list, i, ref); i++) - lto_output_ref (ob, ref, encoder, varpool_encoder); + lto_output_ref (ob, ref, encoder); } } @@ -745,11 +664,11 @@ output_refs (cgraph_node_set set, varpool_node_set vset, { streamer_write_uhwi_stream (ob->main_stream, count); streamer_write_uhwi_stream (ob->main_stream, - lto_varpool_encoder_lookup (varpool_encoder, - node)); + lto_symtab_encoder_lookup (encoder, + (symtab_node)node)); for (i = 0; ipa_ref_list_reference_iterate (&node->symbol.ref_list, i, ref); i++) - lto_output_ref (ob, ref, encoder, varpool_encoder); + lto_output_ref (ob, ref, encoder); } } @@ -769,43 +688,45 @@ compute_ltrans_boundary (struct lto_out_decl_state *state, varpool_node_set_iterator vsi; struct cgraph_edge *edge; int i; - lto_cgraph_encoder_t encoder; - lto_varpool_encoder_t varpool_encoder; + lto_symtab_encoder_t encoder; - encoder = state->cgraph_node_encoder = lto_cgraph_encoder_new (); - varpool_encoder = state->varpool_node_encoder = lto_varpool_encoder_new (); + encoder = state->symtab_node_encoder = lto_symtab_encoder_new (); /* Go over all the nodes in SET and assign references. */ for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) { node = csi_node (csi); add_node_to (encoder, node, true); - add_references (encoder, varpool_encoder, &node->symbol.ref_list); + add_references (encoder, &node->symbol.ref_list); } for (vsi = vsi_start (vset); !vsi_end_p (vsi); vsi_next (&vsi)) { struct varpool_node *vnode = vsi_node (vsi); gcc_assert (!vnode->alias || vnode->alias_of); - lto_varpool_encoder_encode (varpool_encoder, vnode); - lto_set_varpool_encoder_encode_initializer (varpool_encoder, vnode); - add_references (encoder, varpool_encoder, &vnode->symbol.ref_list); + lto_symtab_encoder_encode (encoder, (symtab_node)vnode); + lto_set_symtab_encoder_encode_initializer (encoder, vnode); + add_references (encoder, &vnode->symbol.ref_list); } /* Pickle in also the initializer of all referenced readonly variables to help folding. Constant pool variables are not shared, so we must pickle those too. */ - for (i = 0; i < lto_varpool_encoder_size (varpool_encoder); i++) + for (i = 0; i < lto_symtab_encoder_size (encoder); i++) { - struct varpool_node *vnode = lto_varpool_encoder_deref (varpool_encoder, i); - if (DECL_INITIAL (vnode->symbol.decl) - && !lto_varpool_encoder_encode_initializer_p (varpool_encoder, - vnode) - && const_value_known_p (vnode->symbol.decl)) + symtab_node node = lto_symtab_encoder_deref (encoder, i); + if (symtab_variable_p (node)) { - lto_set_varpool_encoder_encode_initializer (varpool_encoder, vnode); - add_references (encoder, varpool_encoder, &vnode->symbol.ref_list); - } - else if (vnode->alias || vnode->alias_of) - add_references (encoder, varpool_encoder, &vnode->symbol.ref_list); + struct varpool_node *vnode = varpool (node); + if (DECL_INITIAL (vnode->symbol.decl) + && !lto_symtab_encoder_encode_initializer_p (encoder, + vnode) + && const_value_known_p (vnode->symbol.decl)) + { + lto_set_symtab_encoder_encode_initializer (encoder, vnode); + add_references (encoder, &vnode->symbol.ref_list); + } + else if (vnode->alias || vnode->alias_of) + add_references (encoder, &vnode->symbol.ref_list); + } } /* Go over all the nodes again to include callees that are not in @@ -835,8 +756,7 @@ output_cgraph (cgraph_node_set set, varpool_node_set vset) struct lto_simple_output_block *ob; cgraph_node_set_iterator csi; int i, n_nodes; - lto_cgraph_encoder_t encoder; - lto_varpool_encoder_t varpool_encoder; + lto_symtab_encoder_t encoder; static bool asm_nodes_output = false; if (flag_wpa) @@ -848,19 +768,22 @@ output_cgraph (cgraph_node_set set, varpool_node_set vset) /* An encoder for cgraph nodes should have been created by ipa_write_summaries_1. */ - gcc_assert (ob->decl_state->cgraph_node_encoder); - gcc_assert (ob->decl_state->varpool_node_encoder); - encoder = ob->decl_state->cgraph_node_encoder; - varpool_encoder = ob->decl_state->varpool_node_encoder; + gcc_assert (ob->decl_state->symtab_node_encoder); + encoder = ob->decl_state->symtab_node_encoder; /* Write out the nodes. We must first output a node and then its clones, otherwise at a time reading back the node there would be nothing to clone from. */ - n_nodes = lto_cgraph_encoder_size (encoder); + n_nodes = lto_symtab_encoder_size (encoder); for (i = 0; i < n_nodes; i++) { - node = lto_cgraph_encoder_deref (encoder, i); - lto_output_node (ob, node, encoder, set, vset); + symtab_node node = lto_symtab_encoder_deref (encoder, i); + if (symtab_function_p (node)) + lto_output_node (ob, cgraph (node), encoder, set, vset); + else + lto_output_varpool_node (ob, varpool (node), encoder, + set, vset); + } /* Go over the nodes in SET again to write edges. */ @@ -885,8 +808,7 @@ output_cgraph (cgraph_node_set set, varpool_node_set vset) lto_output_toplevel_asms (); } - output_varpool (set, vset); - output_refs (set, vset, encoder, varpool_encoder); + output_refs (set, vset, encoder); } /* Overwrite the information in NODE based on FILE_DATA, TAG, FLAGS, @@ -899,7 +821,7 @@ output_cgraph (cgraph_node_set set, varpool_node_set vset) static void input_overwrite_node (struct lto_file_decl_data *file_data, struct cgraph_node *node, - enum LTO_cgraph_tags tag, + enum LTO_symtab_tags tag, struct bitpack_d *bp) { node->symbol.aux = (void *) tag; @@ -916,7 +838,7 @@ input_overwrite_node (struct lto_file_decl_data *file_data, node->abstract_and_needed = bp_unpack_value (bp, 1); node->symbol.used_from_other_partition = bp_unpack_value (bp, 1); node->lowered = bp_unpack_value (bp, 1); - node->analyzed = tag == LTO_cgraph_analyzed_node; + node->analyzed = tag == LTO_symtab_analyzed_node; node->symbol.in_other_partition = bp_unpack_value (bp, 1); if (node->symbol.in_other_partition /* Avoid updating decl when we are seeing just inline clone. @@ -942,38 +864,14 @@ input_overwrite_node (struct lto_file_decl_data *file_data, LDPR_NUM_KNOWN); } -/* Output the part of the cgraph in SET. */ - -static void -output_varpool (cgraph_node_set set, varpool_node_set vset) -{ - struct lto_simple_output_block *ob = lto_create_simple_output_block (LTO_section_varpool); - lto_varpool_encoder_t varpool_encoder = ob->decl_state->varpool_node_encoder; - int len = lto_varpool_encoder_size (varpool_encoder), i; - - streamer_write_uhwi_stream (ob->main_stream, len); - - /* Write out the nodes. We must first output a node and then its clones, - otherwise at a time reading back the node there would be nothing to clone - from. */ - for (i = 0; i < len; i++) - { - lto_output_varpool_node (ob, lto_varpool_encoder_deref (varpool_encoder, i), - varpool_encoder, - set, vset); - } - - lto_destroy_simple_output_block (ob); -} - /* Read a node from input_block IB. TAG is the node's tag just read. Return the node read or overwriten. */ static struct cgraph_node * input_node (struct lto_file_decl_data *file_data, struct lto_input_block *ib, - enum LTO_cgraph_tags tag, - VEC(cgraph_node_ptr, heap) *nodes) + enum LTO_symtab_tags tag, + VEC(symtab_node, heap) *nodes) { tree fn_decl; struct cgraph_node *node; @@ -991,7 +889,7 @@ input_node (struct lto_file_decl_data *file_data, if (clone_ref != LCC_NOT_FOUND) { - node = cgraph_clone_node (VEC_index (cgraph_node_ptr, nodes, clone_ref), fn_decl, + node = cgraph_clone_node (cgraph (VEC_index (symtab_node, nodes, clone_ref)), fn_decl, 0, CGRAPH_FREQ_BASE, false, NULL, false); } else @@ -1004,7 +902,7 @@ input_node (struct lto_file_decl_data *file_data, node->count = streamer_read_hwi (ib); node->count_materialization_scale = streamer_read_hwi (ib); - if (tag == LTO_cgraph_analyzed_node) + if (tag == LTO_symtab_analyzed_node) ref = streamer_read_hwi (ib); ref2 = streamer_read_hwi (ib); @@ -1107,25 +1005,16 @@ input_varpool_node (struct lto_file_decl_data *file_data, static void input_ref (struct lto_input_block *ib, symtab_node referring_node, - VEC(cgraph_node_ptr, heap) *nodes, - VEC(varpool_node_ptr, heap) *varpool_nodes_vec) + VEC(symtab_node, heap) *nodes) { - struct cgraph_node *node = NULL; - struct varpool_node *varpool_node = NULL; + symtab_node node = NULL; struct bitpack_d bp; - int type; enum ipa_ref_use use; bp = streamer_read_bitpack (ib); - type = bp_unpack_value (&bp, 1); use = (enum ipa_ref_use) bp_unpack_value (&bp, 2); - if (type) - node = VEC_index (cgraph_node_ptr, nodes, streamer_read_hwi (ib)); - else - varpool_node = VEC_index (varpool_node_ptr, varpool_nodes_vec, - streamer_read_hwi (ib)); - ipa_record_reference (referring_node, - node ? (symtab_node) node : (symtab_node) varpool_node, use, NULL); + node = VEC_index (symtab_node, nodes, streamer_read_hwi (ib)); + ipa_record_reference (referring_node, node, use, NULL); } /* Read an edge from IB. NODES points to a vector of previously read nodes for @@ -1134,7 +1023,7 @@ input_ref (struct lto_input_block *ib, indirect_unknown_callee set). */ static void -input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes, +input_edge (struct lto_input_block *ib, VEC(symtab_node, heap) *nodes, bool indirect) { struct cgraph_node *caller, *callee; @@ -1146,13 +1035,13 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes, struct bitpack_d bp; int ecf_flags = 0; - caller = VEC_index (cgraph_node_ptr, nodes, streamer_read_hwi (ib)); + caller = cgraph (VEC_index (symtab_node, 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 = VEC_index (cgraph_node_ptr, nodes, streamer_read_hwi (ib)); + callee = cgraph (VEC_index (symtab_node, nodes, streamer_read_hwi (ib))); if (callee == NULL || callee->symbol.decl == NULL_TREE) internal_error ("bytecode stream: no callee found while reading edge"); } @@ -1197,117 +1086,85 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes, /* Read a cgraph from IB using the info in FILE_DATA. */ -static VEC(cgraph_node_ptr, heap) * +static VEC(symtab_node, heap) * input_cgraph_1 (struct lto_file_decl_data *file_data, struct lto_input_block *ib) { - enum LTO_cgraph_tags tag; - VEC(cgraph_node_ptr, heap) *nodes = NULL; - struct cgraph_node *node; + enum LTO_symtab_tags tag; + VEC(symtab_node, heap) *nodes = NULL; + symtab_node node; unsigned i; - tag = streamer_read_enum (ib, LTO_cgraph_tags, LTO_cgraph_last_tag); + tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag); order_base = symtab_order; while (tag) { - if (tag == LTO_cgraph_edge) + if (tag == LTO_symtab_edge) input_edge (ib, nodes, false); - else if (tag == LTO_cgraph_indirect_edge) + else if (tag == LTO_symtab_indirect_edge) input_edge (ib, nodes, true); + else if (tag == LTO_symtab_variable) + { + node = (symtab_node)input_varpool_node (file_data, ib); + VEC_safe_push (symtab_node, heap, nodes, node); + lto_symtab_encoder_encode (file_data->symtab_node_encoder, node); + } else { - node = input_node (file_data, ib, tag,nodes); + 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 (cgraph_node_ptr, heap, nodes, node); - lto_cgraph_encoder_encode (file_data->cgraph_node_encoder, node); + VEC_safe_push (symtab_node, heap, nodes, node); + lto_symtab_encoder_encode (file_data->symtab_node_encoder, node); } - tag = streamer_read_enum (ib, LTO_cgraph_tags, LTO_cgraph_last_tag); + tag = streamer_read_enum (ib, LTO_symtab_tags, LTO_symtab_last_tag); } lto_input_toplevel_asms (file_data, order_base); - /* AUX pointers should be all non-zero for nodes read from the stream. */ + /* AUX pointers should be all non-zero for function nodes read from the stream. */ #ifdef ENABLE_CHECKING - FOR_EACH_VEC_ELT (cgraph_node_ptr, nodes, i, node) - gcc_assert (node->symbol.aux); + FOR_EACH_VEC_ELT (symtab_node, nodes, i, node) + gcc_assert (node->symbol.aux || !symtab_function_p (node)); #endif - FOR_EACH_VEC_ELT (cgraph_node_ptr, nodes, i, node) + FOR_EACH_VEC_ELT (symtab_node, nodes, i, node) { - int ref = (int) (intptr_t) node->global.inlined_to; - - /* We share declaration of builtins, so we may read same node twice. */ - if (!node->symbol.aux) - continue; - node->symbol.aux = NULL; - - /* Fixup inlined_to from reference to pointer. */ - if (ref != LCC_NOT_FOUND) - node->global.inlined_to = VEC_index (cgraph_node_ptr, nodes, ref); - else - node->global.inlined_to = NULL; + int ref; + if (symtab_function_p (node)) + { + ref = (int) (intptr_t) cgraph (node)->global.inlined_to; + + /* We share declaration of builtins, so we may read same node twice. */ + if (!node->symbol.aux) + continue; + node->symbol.aux = NULL; + + /* Fixup inlined_to from reference to pointer. */ + if (ref != LCC_NOT_FOUND) + cgraph (node)->global.inlined_to = cgraph (VEC_index (symtab_node, nodes, ref)); + else + cgraph (node)->global.inlined_to = NULL; + } ref = (int) (intptr_t) node->symbol.same_comdat_group; /* Fixup same_comdat_group from reference to pointer. */ if (ref != LCC_NOT_FOUND) - node->symbol.same_comdat_group = (symtab_node)VEC_index (cgraph_node_ptr, nodes, ref); + node->symbol.same_comdat_group = VEC_index (symtab_node, nodes, ref); else node->symbol.same_comdat_group = NULL; } - FOR_EACH_VEC_ELT (cgraph_node_ptr, nodes, i, node) - node->symbol.aux = (void *)1; + FOR_EACH_VEC_ELT (symtab_node, nodes, i, node) + node->symbol.aux = symtab_function_p (node) ? (void *)1 : NULL; return nodes; } -/* Read a varpool from IB using the info in FILE_DATA. */ - -static VEC(varpool_node_ptr, heap) * -input_varpool_1 (struct lto_file_decl_data *file_data, - struct lto_input_block *ib) -{ - unsigned HOST_WIDE_INT len; - VEC(varpool_node_ptr, heap) *varpool = NULL; - int i; - struct varpool_node *node; - - len = streamer_read_uhwi (ib); - while (len) - { - VEC_safe_push (varpool_node_ptr, heap, varpool, - input_varpool_node (file_data, ib)); - len--; - } -#ifdef ENABLE_CHECKING - FOR_EACH_VEC_ELT (varpool_node_ptr, varpool, i, node) - gcc_assert (!node->symbol.aux); -#endif - FOR_EACH_VEC_ELT (varpool_node_ptr, varpool, i, node) - { - int ref = (int) (intptr_t) node->symbol.same_comdat_group; - /* We share declaration of builtins, so we may read same node twice. */ - if (node->symbol.aux) - continue; - node->symbol.aux = (void *)1; - - /* Fixup same_comdat_group from reference to pointer. */ - if (ref != LCC_NOT_FOUND) - node->symbol.same_comdat_group = (symtab_node)VEC_index (varpool_node_ptr, varpool, ref); - else - node->symbol.same_comdat_group = NULL; - } - FOR_EACH_VEC_ELT (varpool_node_ptr, varpool, i, node) - node->symbol.aux = NULL; - return varpool; -} - /* Input ipa_refs. */ static void input_refs (struct lto_input_block *ib, - VEC(cgraph_node_ptr, heap) *nodes, - VEC(varpool_node_ptr, heap) *varpool) + VEC(symtab_node, heap) *nodes) { int count; int idx; @@ -1318,10 +1175,10 @@ input_refs (struct lto_input_block *ib, if (!count) break; idx = streamer_read_uhwi (ib); - node = VEC_index (cgraph_node_ptr, nodes, idx); + node = cgraph (VEC_index (symtab_node, nodes, idx)); while (count) { - input_ref (ib, (symtab_node) node, nodes, varpool); + input_ref (ib, (symtab_node) node, nodes); count--; } } @@ -1331,11 +1188,11 @@ input_refs (struct lto_input_block *ib, count = streamer_read_uhwi (ib); if (!count) break; - node = VEC_index (varpool_node_ptr, varpool, - streamer_read_uhwi (ib)); + node = varpool (VEC_index (symtab_node, nodes, + streamer_read_uhwi (ib))); while (count) { - input_ref (ib, (symtab_node) node, nodes, varpool); + input_ref (ib, (symtab_node) node, nodes); count--; } } @@ -1462,38 +1319,28 @@ input_cgraph (void) const char *data; size_t len; struct lto_input_block *ib; - VEC(cgraph_node_ptr, heap) *nodes; - VEC(varpool_node_ptr, heap) *varpool; + VEC(symtab_node, heap) *nodes; ib = lto_create_simple_input_block (file_data, LTO_section_cgraph, &data, &len); if (!ib) fatal_error ("cannot find LTO cgraph in %s", file_data->file_name); input_profile_summary (ib, file_data); - file_data->cgraph_node_encoder = lto_cgraph_encoder_new (); + file_data->symtab_node_encoder = lto_symtab_encoder_new (); nodes = input_cgraph_1 (file_data, ib); lto_destroy_simple_input_block (file_data, LTO_section_cgraph, ib, data, len); - ib = lto_create_simple_input_block (file_data, LTO_section_varpool, - &data, &len); - if (!ib) - fatal_error ("cannot find LTO varpool in %s", file_data->file_name); - varpool = input_varpool_1 (file_data, ib); - lto_destroy_simple_input_block (file_data, LTO_section_varpool, - ib, data, len); - ib = lto_create_simple_input_block (file_data, LTO_section_refs, &data, &len); if (!ib) fatal_error("cannot find LTO section refs in %s", file_data->file_name); - input_refs (ib, nodes, varpool); + input_refs (ib, nodes); lto_destroy_simple_input_block (file_data, LTO_section_refs, ib, data, len); if (flag_ltrans) input_cgraph_opt_summary (nodes); - VEC_free (cgraph_node_ptr, heap, nodes); - VEC_free (varpool_node_ptr, heap, varpool); + VEC_free (symtab_node, heap, nodes); } merge_profile_summaries (file_data_vec); @@ -1598,27 +1445,28 @@ output_node_opt_summary (struct output_block *ob, static void output_cgraph_opt_summary (cgraph_node_set set) { - struct cgraph_node *node; + symtab_node node; int i, n_nodes; - lto_cgraph_encoder_t encoder; + lto_symtab_encoder_t encoder; struct output_block *ob = create_output_block (LTO_section_cgraph_opt_sum); unsigned count = 0; ob->cgraph_node = NULL; - encoder = ob->decl_state->cgraph_node_encoder; - n_nodes = lto_cgraph_encoder_size (encoder); + encoder = ob->decl_state->symtab_node_encoder; + n_nodes = lto_symtab_encoder_size (encoder); for (i = 0; i < n_nodes; i++) - if (output_cgraph_opt_summary_p (lto_cgraph_encoder_deref (encoder, i), - set)) + if (symtab_function_p (node = lto_symtab_encoder_deref (encoder, i)) + && output_cgraph_opt_summary_p (cgraph (node), set)) count++; streamer_write_uhwi (ob, count); for (i = 0; i < n_nodes; i++) { - node = lto_cgraph_encoder_deref (encoder, i); - if (output_cgraph_opt_summary_p (node, set)) + node = lto_symtab_encoder_deref (encoder, i); + if (symtab_function_p (node) + && output_cgraph_opt_summary_p (cgraph (node), set)) { streamer_write_uhwi (ob, i); - output_node_opt_summary (ob, node, set); + output_node_opt_summary (ob, cgraph (node), set); } } produce_asm (ob, NULL); @@ -1690,7 +1538,7 @@ 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 (cgraph_node_ptr, + const char *data, size_t len, VEC (symtab_node, heap) * nodes) { const struct lto_function_header *header = @@ -1714,7 +1562,7 @@ input_cgraph_opt_section (struct lto_file_decl_data *file_data, for (i = 0; i < count; i++) { int ref = streamer_read_uhwi (&ib_main); - input_node_opt_summary (VEC_index (cgraph_node_ptr, nodes, ref), + input_node_opt_summary (cgraph (VEC_index (symtab_node, nodes, ref)), &ib_main, data_in); } lto_free_section_data (file_data, LTO_section_cgraph_opt_sum, NULL, data, @@ -1725,7 +1573,7 @@ input_cgraph_opt_section (struct lto_file_decl_data *file_data, /* Input optimization summary of cgraph. */ static void -input_cgraph_opt_summary (VEC (cgraph_node_ptr, heap) * nodes) +input_cgraph_opt_summary (VEC (symtab_node, heap) * nodes) { struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data (); struct lto_file_decl_data *file_data; |