Mercurial > hg > CbC > CbC_gcc
diff gcc/lto-streamer-out.c @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
line wrap: on
line diff
--- a/gcc/lto-streamer-out.c Fri Feb 12 23:41:23 2010 +0900 +++ b/gcc/lto-streamer-out.c Mon May 24 12:47:05 2010 +0900 @@ -1,6 +1,6 @@ /* Write the GIMPLE representation to a file stream. - Copyright 2009 Free Software Foundation, Inc. + Copyright 2009, 2010 Free Software Foundation, Inc. Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> Re-implemented by Diego Novillo <dnovillo@google.com> @@ -30,7 +30,6 @@ #include "flags.h" #include "params.h" #include "input.h" -#include "varray.h" #include "hashtab.h" #include "basic-block.h" #include "tree-flow.h" @@ -468,6 +467,7 @@ { bp_pack_value (bp, DECL_HARD_REGISTER (expr), 1); bp_pack_value (bp, DECL_IN_TEXT_SECTION (expr), 1); + bp_pack_value (bp, DECL_IN_CONSTANT_POOL (expr), 1); bp_pack_value (bp, DECL_TLS_MODEL (expr), 3); } @@ -517,9 +517,9 @@ bp_pack_value (bp, TYPE_MODE (expr), 7); bp_pack_value (bp, TYPE_STRING_FLAG (expr), 1); bp_pack_value (bp, TYPE_NO_FORCE_BLK (expr), 1); - bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING(expr), 1); - if (TREE_CODE (expr) == UNION_TYPE) - bp_pack_value (bp, TYPE_TRANSPARENT_UNION (expr), 1); + bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING (expr), 1); + if (RECORD_OR_UNION_TYPE_P (expr)) + bp_pack_value (bp, TYPE_TRANSPARENT_AGGR (expr), 1); bp_pack_value (bp, TYPE_PACKED (expr), 1); bp_pack_value (bp, TYPE_RESTRICT (expr), 1); bp_pack_value (bp, TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr), 2); @@ -844,7 +844,23 @@ lto_output_tree_or_ref (ob, DECL_SIZE_UNIT (expr), ref_p); if (TREE_CODE (expr) != FUNCTION_DECL) - lto_output_tree_or_ref (ob, DECL_INITIAL (expr), ref_p); + { + tree initial = DECL_INITIAL (expr); + if (TREE_CODE (expr) == VAR_DECL + && (TREE_STATIC (expr) || DECL_EXTERNAL (expr)) + && initial) + { + lto_varpool_encoder_t varpool_encoder = ob->decl_state->varpool_node_encoder; + struct varpool_node *vnode = varpool_get_node (expr); + if (!vnode) + initial = error_mark_node; + else if (!lto_varpool_encoder_encode_initializer_p (varpool_encoder, + vnode)) + initial = NULL; + } + + lto_output_tree_or_ref (ob, initial, ref_p); + } lto_output_tree_or_ref (ob, DECL_ATTRIBUTES (expr), ref_p); lto_output_tree_or_ref (ob, DECL_ABSTRACT_ORIGIN (expr), ref_p); @@ -946,9 +962,10 @@ lto_output_tree_or_ref (ob, TYPE_VALUES (expr), ref_p); else if (TREE_CODE (expr) == ARRAY_TYPE) lto_output_tree_or_ref (ob, TYPE_DOMAIN (expr), ref_p); - else if (TREE_CODE (expr) == RECORD_TYPE || TREE_CODE (expr) == UNION_TYPE) + else if (RECORD_OR_UNION_TYPE_P (expr)) lto_output_tree_or_ref (ob, TYPE_FIELDS (expr), ref_p); - else if (TREE_CODE (expr) == FUNCTION_TYPE || TREE_CODE (expr) == METHOD_TYPE) + else if (TREE_CODE (expr) == FUNCTION_TYPE + || TREE_CODE (expr) == METHOD_TYPE) lto_output_tree_or_ref (ob, TYPE_ARG_TYPES (expr), ref_p); else if (TREE_CODE (expr) == VECTOR_TYPE) lto_output_tree_or_ref (ob, TYPE_DEBUG_REPRESENTATION_TYPE (expr), ref_p); @@ -965,7 +982,7 @@ lto_output_tree_or_ref (ob, TYPE_MAIN_VARIANT (expr), ref_p); /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists during fixup. */ - if (TREE_CODE (expr) == RECORD_TYPE || TREE_CODE (expr) == UNION_TYPE) + if (RECORD_OR_UNION_TYPE_P (expr)) lto_output_tree_or_ref (ob, TYPE_BINFO (expr), ref_p); lto_output_tree_or_ref (ob, TYPE_CONTEXT (expr), ref_p); lto_output_tree_or_ref (ob, TYPE_CANONICAL (expr), ref_p); @@ -1685,6 +1702,7 @@ lto_output_uleb128_stream (ob->main_stream, gimple_asm_ninputs (stmt)); lto_output_uleb128_stream (ob->main_stream, gimple_asm_noutputs (stmt)); lto_output_uleb128_stream (ob->main_stream, gimple_asm_nclobbers (stmt)); + lto_output_uleb128_stream (ob->main_stream, gimple_asm_nlabels (stmt)); output_string (ob, ob->main_stream, gimple_asm_string (stmt)); /* Fallthru */ @@ -1784,8 +1802,6 @@ if (section_type == LTO_section_function_body) { const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fn)); - if (name[0] == '*') - name++; section_name = lto_get_section_name (section_type, name); } else @@ -1868,12 +1884,14 @@ bp_pack_value (bp, fn->has_nonlocal_label, 1); bp_pack_value (bp, fn->calls_alloca, 1); bp_pack_value (bp, fn->calls_setjmp, 1); - bp_pack_value (bp, fn->function_frequency, 2); bp_pack_value (bp, fn->va_list_fpr_size, 8); bp_pack_value (bp, fn->va_list_gpr_size, 8); lto_output_bitpack (ob->main_stream, bp); bitpack_delete (bp); + /* Output current IL state of the function. */ + output_uleb128 (ob, fn->curr_properties); + /* Output the static chain and non-local goto save area. */ lto_output_tree_ref (ob, fn->static_chain_decl); lto_output_tree_ref (ob, fn->nonlocal_goto_save_area); @@ -1928,22 +1946,14 @@ the file processed by LTRANS. */ static bool -output_alias_pair_p (alias_pair *p, cgraph_node_set set) +output_alias_pair_p (alias_pair *p, cgraph_node_set set, varpool_node_set vset) { - cgraph_node_set_iterator csi; - struct cgraph_node *target_node; - - /* Always emit VAR_DECLs. FIXME lto, we should probably only emit - those VAR_DECLs that are instantiated in this file partition, but - we have no easy way of knowing this based on SET. */ if (TREE_CODE (p->decl) == VAR_DECL) - return true; + return varpool_node_in_set_p (varpool_node_for_asm (p->target), vset); /* Check if the assembler name for P->TARGET has its cgraph node in SET. */ gcc_assert (TREE_CODE (p->decl) == FUNCTION_DECL); - target_node = cgraph_node_for_asm (p->target); - csi = cgraph_node_set_find (set, target_node); - return (!csi_end_p (csi)); + return cgraph_node_in_set_p (cgraph_node_for_asm (p->target), set); } @@ -1951,7 +1961,7 @@ and labels. */ static void -output_unreferenced_globals (cgraph_node_set set) +output_unreferenced_globals (cgraph_node_set set, varpool_node_set vset) { struct output_block *ob; alias_pair *p; @@ -1972,19 +1982,28 @@ symbols at link time if a file defines a global symbol but never references it. */ FOR_EACH_STATIC_VARIABLE (vnode) - { - tree var = vnode->decl; - - if (TREE_CODE (var) == VAR_DECL && TREE_PUBLIC (var)) - lto_output_tree_ref (ob, var); - } + if (vnode->needed && varpool_node_in_set_p (vnode, vset)) + { + tree var = vnode->decl; + + if (TREE_CODE (var) == VAR_DECL) + { + /* Output the object in order to output references used in the + initialization. */ + lto_output_tree (ob, var, true); + + /* If it is public we also need a reference to the object itself. */ + if (TREE_PUBLIC (var)) + lto_output_tree_ref (ob, var); + } + } output_zero (ob); /* Emit the alias pairs for the nodes in SET. */ for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p); i++) { - if (output_alias_pair_p (p, set)) + if (output_alias_pair_p (p, set, vset)) { lto_output_tree_ref (ob, p->decl); lto_output_tree_ref (ob, p->target); @@ -2009,16 +2028,11 @@ const char *data; size_t len; const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function)); - char *section_name; + char *section_name = + lto_get_section_name (LTO_section_function_body, name); size_t i, j; struct lto_in_decl_state *in_state; - struct lto_out_decl_state *out_state; - - if (name[0] == '*') - name++; - section_name = - lto_get_section_name (LTO_section_function_body, name); - out_state = lto_get_out_decl_state (); + struct lto_out_decl_state *out_state = lto_get_out_decl_state (); lto_begin_section (section_name, !flag_wpa); free (section_name); @@ -2073,22 +2087,29 @@ /* Main entry point from the pass manager. */ static void -lto_output (cgraph_node_set set) +lto_output (cgraph_node_set set, varpool_node_set vset) { struct cgraph_node *node; struct lto_out_decl_state *decl_state; - cgraph_node_set_iterator csi; +#ifdef ENABLE_CHECKING bitmap output = lto_bitmap_alloc (); +#endif + int i, n_nodes; + lto_cgraph_encoder_t encoder = lto_get_out_decl_state ()->cgraph_node_encoder; lto_writer_init (); + n_nodes = lto_cgraph_encoder_size (encoder); /* Process only the functions with bodies. */ - for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) + for (i = 0; i < n_nodes; i++) { - node = csi_node (csi); - if (node->analyzed && !bitmap_bit_p (output, DECL_UID (node->decl))) + node = lto_cgraph_encoder_deref (encoder, i); + if (lto_cgraph_encoder_encode_body_p (encoder, node)) { +#ifdef ENABLE_CHECKING + gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl))); bitmap_set_bit (output, DECL_UID (node->decl)); +#endif decl_state = lto_new_out_decl_state (); lto_push_out_decl_state (decl_state); if (!flag_wpa) @@ -2105,9 +2126,11 @@ be done now to make sure that all the statements in every function have been renumbered so that edges can be associated with call statements using the statement UIDs. */ - output_cgraph (set); - + output_cgraph (set, vset); + +#ifdef ENABLE_CHECKING lto_bitmap_free (output); +#endif } struct ipa_opt_pass_d pass_ipa_lto_gimple_out = @@ -2130,7 +2153,8 @@ NULL, /* generate_summary */ lto_output, /* write_summary */ NULL, /* read_summary */ - NULL, /* function_read_summary */ + lto_output, /* write_optimization_summary */ + NULL, /* read_optimization_summary */ NULL, /* stmt_fixup */ 0, /* TODOs */ NULL, /* function_transform */ @@ -2159,20 +2183,6 @@ t = lto_tree_ref_encoder_get_tree (encoder, index); if (!lto_streamer_cache_lookup (ob->writer_cache, t, NULL)) lto_output_tree (ob, t, false); - - if (flag_wpa) - { - /* In WPA we should not emit multiple definitions of the - same symbol to all the files in the link set. If - T had already been emitted as the pervailing definition - in one file, do not emit it in the others. */ - /* FIXME lto. We should check if T belongs to the - file we are writing to. */ - if (TREE_CODE (t) == VAR_DECL - && TREE_PUBLIC (t) - && !DECL_EXTERNAL (t)) - TREE_ASM_WRITTEN (t) = 1; - } } } @@ -2425,7 +2435,7 @@ recover these on other side. */ static void -produce_asm_for_decls (cgraph_node_set set) +produce_asm_for_decls (cgraph_node_set set, varpool_node_set vset) { struct lto_out_decl_state *out_state; struct lto_out_decl_state *fn_out_state; @@ -2443,7 +2453,7 @@ /* Write out unreferenced globals, alias pairs and labels. We defer doing this until now so that we can write out only what is needed. */ - output_unreferenced_globals (set); + output_unreferenced_globals (set, vset); memset (&header, 0, sizeof (struct lto_decl_header)); @@ -2521,7 +2531,14 @@ lto_write_options (); /* Deallocate memory and clean up. */ + for (idx = 0; idx < num_fns; idx++) + { + fn_out_state = + VEC_index (lto_out_decl_state_ptr, lto_function_decl_states, idx); + lto_delete_out_decl_state (fn_out_state); + } lto_cgraph_encoder_delete (ob->decl_state->cgraph_node_encoder); + lto_varpool_encoder_delete (ob->decl_state->varpool_node_encoder); VEC_free (lto_out_decl_state_ptr, heap, lto_function_decl_states); lto_function_decl_states = NULL; destroy_output_block (ob); @@ -2548,7 +2565,8 @@ NULL, /* generate_summary */ produce_asm_for_decls, /* write_summary */ NULL, /* read_summary */ - NULL, /* function_read_summary */ + produce_asm_for_decls, /* write_optimization_summary */ + NULL, /* read_optimization_summary */ NULL, /* stmt_fixup */ 0, /* TODOs */ NULL, /* function_transform */