Mercurial > hg > CbC > CbC_gcc
comparison 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 |
comparison
equal
deleted
inserted
replaced
56:3c8a44c06a95 | 63:b7f97abdc517 |
---|---|
1 /* Write the GIMPLE representation to a file stream. | 1 /* Write the GIMPLE representation to a file stream. |
2 | 2 |
3 Copyright 2009 Free Software Foundation, Inc. | 3 Copyright 2009, 2010 Free Software Foundation, Inc. |
4 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> | 4 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> |
5 Re-implemented by Diego Novillo <dnovillo@google.com> | 5 Re-implemented by Diego Novillo <dnovillo@google.com> |
6 | 6 |
7 This file is part of GCC. | 7 This file is part of GCC. |
8 | 8 |
28 #include "tree.h" | 28 #include "tree.h" |
29 #include "expr.h" | 29 #include "expr.h" |
30 #include "flags.h" | 30 #include "flags.h" |
31 #include "params.h" | 31 #include "params.h" |
32 #include "input.h" | 32 #include "input.h" |
33 #include "varray.h" | |
34 #include "hashtab.h" | 33 #include "hashtab.h" |
35 #include "basic-block.h" | 34 #include "basic-block.h" |
36 #include "tree-flow.h" | 35 #include "tree-flow.h" |
37 #include "tree-pass.h" | 36 #include "tree-pass.h" |
38 #include "cgraph.h" | 37 #include "cgraph.h" |
466 | 465 |
467 if (TREE_CODE (expr) == VAR_DECL) | 466 if (TREE_CODE (expr) == VAR_DECL) |
468 { | 467 { |
469 bp_pack_value (bp, DECL_HARD_REGISTER (expr), 1); | 468 bp_pack_value (bp, DECL_HARD_REGISTER (expr), 1); |
470 bp_pack_value (bp, DECL_IN_TEXT_SECTION (expr), 1); | 469 bp_pack_value (bp, DECL_IN_TEXT_SECTION (expr), 1); |
470 bp_pack_value (bp, DECL_IN_CONSTANT_POOL (expr), 1); | |
471 bp_pack_value (bp, DECL_TLS_MODEL (expr), 3); | 471 bp_pack_value (bp, DECL_TLS_MODEL (expr), 3); |
472 } | 472 } |
473 | 473 |
474 if (VAR_OR_FUNCTION_DECL_P (expr)) | 474 if (VAR_OR_FUNCTION_DECL_P (expr)) |
475 bp_pack_value (bp, DECL_INIT_PRIORITY (expr), HOST_BITS_PER_SHORT); | 475 bp_pack_value (bp, DECL_INIT_PRIORITY (expr), HOST_BITS_PER_SHORT); |
515 { | 515 { |
516 bp_pack_value (bp, TYPE_PRECISION (expr), 9); | 516 bp_pack_value (bp, TYPE_PRECISION (expr), 9); |
517 bp_pack_value (bp, TYPE_MODE (expr), 7); | 517 bp_pack_value (bp, TYPE_MODE (expr), 7); |
518 bp_pack_value (bp, TYPE_STRING_FLAG (expr), 1); | 518 bp_pack_value (bp, TYPE_STRING_FLAG (expr), 1); |
519 bp_pack_value (bp, TYPE_NO_FORCE_BLK (expr), 1); | 519 bp_pack_value (bp, TYPE_NO_FORCE_BLK (expr), 1); |
520 bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING(expr), 1); | 520 bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING (expr), 1); |
521 if (TREE_CODE (expr) == UNION_TYPE) | 521 if (RECORD_OR_UNION_TYPE_P (expr)) |
522 bp_pack_value (bp, TYPE_TRANSPARENT_UNION (expr), 1); | 522 bp_pack_value (bp, TYPE_TRANSPARENT_AGGR (expr), 1); |
523 bp_pack_value (bp, TYPE_PACKED (expr), 1); | 523 bp_pack_value (bp, TYPE_PACKED (expr), 1); |
524 bp_pack_value (bp, TYPE_RESTRICT (expr), 1); | 524 bp_pack_value (bp, TYPE_RESTRICT (expr), 1); |
525 bp_pack_value (bp, TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr), 2); | 525 bp_pack_value (bp, TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr), 2); |
526 bp_pack_value (bp, TYPE_USER_ALIGN (expr), 1); | 526 bp_pack_value (bp, TYPE_USER_ALIGN (expr), 1); |
527 bp_pack_value (bp, TYPE_READONLY (expr), 1); | 527 bp_pack_value (bp, TYPE_READONLY (expr), 1); |
842 { | 842 { |
843 lto_output_tree_or_ref (ob, DECL_SIZE (expr), ref_p); | 843 lto_output_tree_or_ref (ob, DECL_SIZE (expr), ref_p); |
844 lto_output_tree_or_ref (ob, DECL_SIZE_UNIT (expr), ref_p); | 844 lto_output_tree_or_ref (ob, DECL_SIZE_UNIT (expr), ref_p); |
845 | 845 |
846 if (TREE_CODE (expr) != FUNCTION_DECL) | 846 if (TREE_CODE (expr) != FUNCTION_DECL) |
847 lto_output_tree_or_ref (ob, DECL_INITIAL (expr), ref_p); | 847 { |
848 tree initial = DECL_INITIAL (expr); | |
849 if (TREE_CODE (expr) == VAR_DECL | |
850 && (TREE_STATIC (expr) || DECL_EXTERNAL (expr)) | |
851 && initial) | |
852 { | |
853 lto_varpool_encoder_t varpool_encoder = ob->decl_state->varpool_node_encoder; | |
854 struct varpool_node *vnode = varpool_get_node (expr); | |
855 if (!vnode) | |
856 initial = error_mark_node; | |
857 else if (!lto_varpool_encoder_encode_initializer_p (varpool_encoder, | |
858 vnode)) | |
859 initial = NULL; | |
860 } | |
861 | |
862 lto_output_tree_or_ref (ob, initial, ref_p); | |
863 } | |
848 | 864 |
849 lto_output_tree_or_ref (ob, DECL_ATTRIBUTES (expr), ref_p); | 865 lto_output_tree_or_ref (ob, DECL_ATTRIBUTES (expr), ref_p); |
850 lto_output_tree_or_ref (ob, DECL_ABSTRACT_ORIGIN (expr), ref_p); | 866 lto_output_tree_or_ref (ob, DECL_ABSTRACT_ORIGIN (expr), ref_p); |
851 | 867 |
852 if (TREE_CODE (expr) == PARM_DECL) | 868 if (TREE_CODE (expr) == PARM_DECL) |
944 { | 960 { |
945 if (TREE_CODE (expr) == ENUMERAL_TYPE) | 961 if (TREE_CODE (expr) == ENUMERAL_TYPE) |
946 lto_output_tree_or_ref (ob, TYPE_VALUES (expr), ref_p); | 962 lto_output_tree_or_ref (ob, TYPE_VALUES (expr), ref_p); |
947 else if (TREE_CODE (expr) == ARRAY_TYPE) | 963 else if (TREE_CODE (expr) == ARRAY_TYPE) |
948 lto_output_tree_or_ref (ob, TYPE_DOMAIN (expr), ref_p); | 964 lto_output_tree_or_ref (ob, TYPE_DOMAIN (expr), ref_p); |
949 else if (TREE_CODE (expr) == RECORD_TYPE || TREE_CODE (expr) == UNION_TYPE) | 965 else if (RECORD_OR_UNION_TYPE_P (expr)) |
950 lto_output_tree_or_ref (ob, TYPE_FIELDS (expr), ref_p); | 966 lto_output_tree_or_ref (ob, TYPE_FIELDS (expr), ref_p); |
951 else if (TREE_CODE (expr) == FUNCTION_TYPE || TREE_CODE (expr) == METHOD_TYPE) | 967 else if (TREE_CODE (expr) == FUNCTION_TYPE |
968 || TREE_CODE (expr) == METHOD_TYPE) | |
952 lto_output_tree_or_ref (ob, TYPE_ARG_TYPES (expr), ref_p); | 969 lto_output_tree_or_ref (ob, TYPE_ARG_TYPES (expr), ref_p); |
953 else if (TREE_CODE (expr) == VECTOR_TYPE) | 970 else if (TREE_CODE (expr) == VECTOR_TYPE) |
954 lto_output_tree_or_ref (ob, TYPE_DEBUG_REPRESENTATION_TYPE (expr), ref_p); | 971 lto_output_tree_or_ref (ob, TYPE_DEBUG_REPRESENTATION_TYPE (expr), ref_p); |
955 | 972 |
956 lto_output_tree_or_ref (ob, TYPE_SIZE (expr), ref_p); | 973 lto_output_tree_or_ref (ob, TYPE_SIZE (expr), ref_p); |
963 lto_output_tree_or_ref (ob, TYPE_MINVAL (expr), ref_p); | 980 lto_output_tree_or_ref (ob, TYPE_MINVAL (expr), ref_p); |
964 lto_output_tree_or_ref (ob, TYPE_MAXVAL (expr), ref_p); | 981 lto_output_tree_or_ref (ob, TYPE_MAXVAL (expr), ref_p); |
965 lto_output_tree_or_ref (ob, TYPE_MAIN_VARIANT (expr), ref_p); | 982 lto_output_tree_or_ref (ob, TYPE_MAIN_VARIANT (expr), ref_p); |
966 /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists | 983 /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists |
967 during fixup. */ | 984 during fixup. */ |
968 if (TREE_CODE (expr) == RECORD_TYPE || TREE_CODE (expr) == UNION_TYPE) | 985 if (RECORD_OR_UNION_TYPE_P (expr)) |
969 lto_output_tree_or_ref (ob, TYPE_BINFO (expr), ref_p); | 986 lto_output_tree_or_ref (ob, TYPE_BINFO (expr), ref_p); |
970 lto_output_tree_or_ref (ob, TYPE_CONTEXT (expr), ref_p); | 987 lto_output_tree_or_ref (ob, TYPE_CONTEXT (expr), ref_p); |
971 lto_output_tree_or_ref (ob, TYPE_CANONICAL (expr), ref_p); | 988 lto_output_tree_or_ref (ob, TYPE_CANONICAL (expr), ref_p); |
972 lto_output_tree_or_ref (ob, TYPE_STUB_DECL (expr), ref_p); | 989 lto_output_tree_or_ref (ob, TYPE_STUB_DECL (expr), ref_p); |
973 } | 990 } |
1683 | 1700 |
1684 case GIMPLE_ASM: | 1701 case GIMPLE_ASM: |
1685 lto_output_uleb128_stream (ob->main_stream, gimple_asm_ninputs (stmt)); | 1702 lto_output_uleb128_stream (ob->main_stream, gimple_asm_ninputs (stmt)); |
1686 lto_output_uleb128_stream (ob->main_stream, gimple_asm_noutputs (stmt)); | 1703 lto_output_uleb128_stream (ob->main_stream, gimple_asm_noutputs (stmt)); |
1687 lto_output_uleb128_stream (ob->main_stream, gimple_asm_nclobbers (stmt)); | 1704 lto_output_uleb128_stream (ob->main_stream, gimple_asm_nclobbers (stmt)); |
1705 lto_output_uleb128_stream (ob->main_stream, gimple_asm_nlabels (stmt)); | |
1688 output_string (ob, ob->main_stream, gimple_asm_string (stmt)); | 1706 output_string (ob, ob->main_stream, gimple_asm_string (stmt)); |
1689 /* Fallthru */ | 1707 /* Fallthru */ |
1690 | 1708 |
1691 case GIMPLE_ASSIGN: | 1709 case GIMPLE_ASSIGN: |
1692 case GIMPLE_CALL: | 1710 case GIMPLE_CALL: |
1782 struct lto_output_stream *header_stream; | 1800 struct lto_output_stream *header_stream; |
1783 | 1801 |
1784 if (section_type == LTO_section_function_body) | 1802 if (section_type == LTO_section_function_body) |
1785 { | 1803 { |
1786 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fn)); | 1804 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fn)); |
1787 if (name[0] == '*') | |
1788 name++; | |
1789 section_name = lto_get_section_name (section_type, name); | 1805 section_name = lto_get_section_name (section_type, name); |
1790 } | 1806 } |
1791 else | 1807 else |
1792 section_name = lto_get_section_name (section_type, NULL); | 1808 section_name = lto_get_section_name (section_type, NULL); |
1793 | 1809 |
1866 bp_pack_value (bp, fn->dont_save_pending_sizes_p, 1); | 1882 bp_pack_value (bp, fn->dont_save_pending_sizes_p, 1); |
1867 bp_pack_value (bp, fn->stdarg, 1); | 1883 bp_pack_value (bp, fn->stdarg, 1); |
1868 bp_pack_value (bp, fn->has_nonlocal_label, 1); | 1884 bp_pack_value (bp, fn->has_nonlocal_label, 1); |
1869 bp_pack_value (bp, fn->calls_alloca, 1); | 1885 bp_pack_value (bp, fn->calls_alloca, 1); |
1870 bp_pack_value (bp, fn->calls_setjmp, 1); | 1886 bp_pack_value (bp, fn->calls_setjmp, 1); |
1871 bp_pack_value (bp, fn->function_frequency, 2); | |
1872 bp_pack_value (bp, fn->va_list_fpr_size, 8); | 1887 bp_pack_value (bp, fn->va_list_fpr_size, 8); |
1873 bp_pack_value (bp, fn->va_list_gpr_size, 8); | 1888 bp_pack_value (bp, fn->va_list_gpr_size, 8); |
1874 lto_output_bitpack (ob->main_stream, bp); | 1889 lto_output_bitpack (ob->main_stream, bp); |
1875 bitpack_delete (bp); | 1890 bitpack_delete (bp); |
1891 | |
1892 /* Output current IL state of the function. */ | |
1893 output_uleb128 (ob, fn->curr_properties); | |
1876 | 1894 |
1877 /* Output the static chain and non-local goto save area. */ | 1895 /* Output the static chain and non-local goto save area. */ |
1878 lto_output_tree_ref (ob, fn->static_chain_decl); | 1896 lto_output_tree_ref (ob, fn->static_chain_decl); |
1879 lto_output_tree_ref (ob, fn->nonlocal_goto_save_area); | 1897 lto_output_tree_ref (ob, fn->nonlocal_goto_save_area); |
1880 | 1898 |
1926 Otherwise, the LTRANS phase will get into trouble when finalizing | 1944 Otherwise, the LTRANS phase will get into trouble when finalizing |
1927 aliases because the alias will refer to a function not defined in | 1945 aliases because the alias will refer to a function not defined in |
1928 the file processed by LTRANS. */ | 1946 the file processed by LTRANS. */ |
1929 | 1947 |
1930 static bool | 1948 static bool |
1931 output_alias_pair_p (alias_pair *p, cgraph_node_set set) | 1949 output_alias_pair_p (alias_pair *p, cgraph_node_set set, varpool_node_set vset) |
1932 { | 1950 { |
1933 cgraph_node_set_iterator csi; | |
1934 struct cgraph_node *target_node; | |
1935 | |
1936 /* Always emit VAR_DECLs. FIXME lto, we should probably only emit | |
1937 those VAR_DECLs that are instantiated in this file partition, but | |
1938 we have no easy way of knowing this based on SET. */ | |
1939 if (TREE_CODE (p->decl) == VAR_DECL) | 1951 if (TREE_CODE (p->decl) == VAR_DECL) |
1940 return true; | 1952 return varpool_node_in_set_p (varpool_node_for_asm (p->target), vset); |
1941 | 1953 |
1942 /* Check if the assembler name for P->TARGET has its cgraph node in SET. */ | 1954 /* Check if the assembler name for P->TARGET has its cgraph node in SET. */ |
1943 gcc_assert (TREE_CODE (p->decl) == FUNCTION_DECL); | 1955 gcc_assert (TREE_CODE (p->decl) == FUNCTION_DECL); |
1944 target_node = cgraph_node_for_asm (p->target); | 1956 return cgraph_node_in_set_p (cgraph_node_for_asm (p->target), set); |
1945 csi = cgraph_node_set_find (set, target_node); | |
1946 return (!csi_end_p (csi)); | |
1947 } | 1957 } |
1948 | 1958 |
1949 | 1959 |
1950 /* Output any unreferenced global symbol defined in SET, alias pairs | 1960 /* Output any unreferenced global symbol defined in SET, alias pairs |
1951 and labels. */ | 1961 and labels. */ |
1952 | 1962 |
1953 static void | 1963 static void |
1954 output_unreferenced_globals (cgraph_node_set set) | 1964 output_unreferenced_globals (cgraph_node_set set, varpool_node_set vset) |
1955 { | 1965 { |
1956 struct output_block *ob; | 1966 struct output_block *ob; |
1957 alias_pair *p; | 1967 alias_pair *p; |
1958 unsigned i; | 1968 unsigned i; |
1959 struct varpool_node *vnode; | 1969 struct varpool_node *vnode; |
1970 was never referenced in any of the functions of this file, it | 1980 was never referenced in any of the functions of this file, it |
1971 would not be emitted otherwise. This will result in unreferenced | 1981 would not be emitted otherwise. This will result in unreferenced |
1972 symbols at link time if a file defines a global symbol but | 1982 symbols at link time if a file defines a global symbol but |
1973 never references it. */ | 1983 never references it. */ |
1974 FOR_EACH_STATIC_VARIABLE (vnode) | 1984 FOR_EACH_STATIC_VARIABLE (vnode) |
1975 { | 1985 if (vnode->needed && varpool_node_in_set_p (vnode, vset)) |
1976 tree var = vnode->decl; | 1986 { |
1977 | 1987 tree var = vnode->decl; |
1978 if (TREE_CODE (var) == VAR_DECL && TREE_PUBLIC (var)) | 1988 |
1979 lto_output_tree_ref (ob, var); | 1989 if (TREE_CODE (var) == VAR_DECL) |
1980 } | 1990 { |
1991 /* Output the object in order to output references used in the | |
1992 initialization. */ | |
1993 lto_output_tree (ob, var, true); | |
1994 | |
1995 /* If it is public we also need a reference to the object itself. */ | |
1996 if (TREE_PUBLIC (var)) | |
1997 lto_output_tree_ref (ob, var); | |
1998 } | |
1999 } | |
1981 | 2000 |
1982 output_zero (ob); | 2001 output_zero (ob); |
1983 | 2002 |
1984 /* Emit the alias pairs for the nodes in SET. */ | 2003 /* Emit the alias pairs for the nodes in SET. */ |
1985 for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p); i++) | 2004 for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p); i++) |
1986 { | 2005 { |
1987 if (output_alias_pair_p (p, set)) | 2006 if (output_alias_pair_p (p, set, vset)) |
1988 { | 2007 { |
1989 lto_output_tree_ref (ob, p->decl); | 2008 lto_output_tree_ref (ob, p->decl); |
1990 lto_output_tree_ref (ob, p->target); | 2009 lto_output_tree_ref (ob, p->target); |
1991 } | 2010 } |
1992 } | 2011 } |
2007 struct lto_file_decl_data *file_data = node->local.lto_file_data; | 2026 struct lto_file_decl_data *file_data = node->local.lto_file_data; |
2008 struct lto_output_stream *output_stream = XCNEW (struct lto_output_stream); | 2027 struct lto_output_stream *output_stream = XCNEW (struct lto_output_stream); |
2009 const char *data; | 2028 const char *data; |
2010 size_t len; | 2029 size_t len; |
2011 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function)); | 2030 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function)); |
2012 char *section_name; | 2031 char *section_name = |
2032 lto_get_section_name (LTO_section_function_body, name); | |
2013 size_t i, j; | 2033 size_t i, j; |
2014 struct lto_in_decl_state *in_state; | 2034 struct lto_in_decl_state *in_state; |
2015 struct lto_out_decl_state *out_state; | 2035 struct lto_out_decl_state *out_state = lto_get_out_decl_state (); |
2016 | |
2017 if (name[0] == '*') | |
2018 name++; | |
2019 section_name = | |
2020 lto_get_section_name (LTO_section_function_body, name); | |
2021 out_state = lto_get_out_decl_state (); | |
2022 | 2036 |
2023 lto_begin_section (section_name, !flag_wpa); | 2037 lto_begin_section (section_name, !flag_wpa); |
2024 free (section_name); | 2038 free (section_name); |
2025 | 2039 |
2026 /* We may have renamed the declaration, e.g., a static function. */ | 2040 /* We may have renamed the declaration, e.g., a static function. */ |
2071 | 2085 |
2072 | 2086 |
2073 /* Main entry point from the pass manager. */ | 2087 /* Main entry point from the pass manager. */ |
2074 | 2088 |
2075 static void | 2089 static void |
2076 lto_output (cgraph_node_set set) | 2090 lto_output (cgraph_node_set set, varpool_node_set vset) |
2077 { | 2091 { |
2078 struct cgraph_node *node; | 2092 struct cgraph_node *node; |
2079 struct lto_out_decl_state *decl_state; | 2093 struct lto_out_decl_state *decl_state; |
2080 cgraph_node_set_iterator csi; | 2094 #ifdef ENABLE_CHECKING |
2081 bitmap output = lto_bitmap_alloc (); | 2095 bitmap output = lto_bitmap_alloc (); |
2096 #endif | |
2097 int i, n_nodes; | |
2098 lto_cgraph_encoder_t encoder = lto_get_out_decl_state ()->cgraph_node_encoder; | |
2082 | 2099 |
2083 lto_writer_init (); | 2100 lto_writer_init (); |
2084 | 2101 |
2102 n_nodes = lto_cgraph_encoder_size (encoder); | |
2085 /* Process only the functions with bodies. */ | 2103 /* Process only the functions with bodies. */ |
2086 for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi)) | 2104 for (i = 0; i < n_nodes; i++) |
2087 { | 2105 { |
2088 node = csi_node (csi); | 2106 node = lto_cgraph_encoder_deref (encoder, i); |
2089 if (node->analyzed && !bitmap_bit_p (output, DECL_UID (node->decl))) | 2107 if (lto_cgraph_encoder_encode_body_p (encoder, node)) |
2090 { | 2108 { |
2109 #ifdef ENABLE_CHECKING | |
2110 gcc_assert (!bitmap_bit_p (output, DECL_UID (node->decl))); | |
2091 bitmap_set_bit (output, DECL_UID (node->decl)); | 2111 bitmap_set_bit (output, DECL_UID (node->decl)); |
2112 #endif | |
2092 decl_state = lto_new_out_decl_state (); | 2113 decl_state = lto_new_out_decl_state (); |
2093 lto_push_out_decl_state (decl_state); | 2114 lto_push_out_decl_state (decl_state); |
2094 if (!flag_wpa) | 2115 if (!flag_wpa) |
2095 output_function (node); | 2116 output_function (node); |
2096 else | 2117 else |
2103 | 2124 |
2104 /* Emit the callgraph after emitting function bodies. This needs to | 2125 /* Emit the callgraph after emitting function bodies. This needs to |
2105 be done now to make sure that all the statements in every function | 2126 be done now to make sure that all the statements in every function |
2106 have been renumbered so that edges can be associated with call | 2127 have been renumbered so that edges can be associated with call |
2107 statements using the statement UIDs. */ | 2128 statements using the statement UIDs. */ |
2108 output_cgraph (set); | 2129 output_cgraph (set, vset); |
2109 | 2130 |
2131 #ifdef ENABLE_CHECKING | |
2110 lto_bitmap_free (output); | 2132 lto_bitmap_free (output); |
2133 #endif | |
2111 } | 2134 } |
2112 | 2135 |
2113 struct ipa_opt_pass_d pass_ipa_lto_gimple_out = | 2136 struct ipa_opt_pass_d pass_ipa_lto_gimple_out = |
2114 { | 2137 { |
2115 { | 2138 { |
2128 TODO_dump_func /* todo_flags_finish */ | 2151 TODO_dump_func /* todo_flags_finish */ |
2129 }, | 2152 }, |
2130 NULL, /* generate_summary */ | 2153 NULL, /* generate_summary */ |
2131 lto_output, /* write_summary */ | 2154 lto_output, /* write_summary */ |
2132 NULL, /* read_summary */ | 2155 NULL, /* read_summary */ |
2133 NULL, /* function_read_summary */ | 2156 lto_output, /* write_optimization_summary */ |
2157 NULL, /* read_optimization_summary */ | |
2134 NULL, /* stmt_fixup */ | 2158 NULL, /* stmt_fixup */ |
2135 0, /* TODOs */ | 2159 0, /* TODOs */ |
2136 NULL, /* function_transform */ | 2160 NULL, /* function_transform */ |
2137 NULL /* variable_transform */ | 2161 NULL /* variable_transform */ |
2138 }; | 2162 }; |
2157 for (index = 0; index < size; index++) | 2181 for (index = 0; index < size; index++) |
2158 { | 2182 { |
2159 t = lto_tree_ref_encoder_get_tree (encoder, index); | 2183 t = lto_tree_ref_encoder_get_tree (encoder, index); |
2160 if (!lto_streamer_cache_lookup (ob->writer_cache, t, NULL)) | 2184 if (!lto_streamer_cache_lookup (ob->writer_cache, t, NULL)) |
2161 lto_output_tree (ob, t, false); | 2185 lto_output_tree (ob, t, false); |
2162 | |
2163 if (flag_wpa) | |
2164 { | |
2165 /* In WPA we should not emit multiple definitions of the | |
2166 same symbol to all the files in the link set. If | |
2167 T had already been emitted as the pervailing definition | |
2168 in one file, do not emit it in the others. */ | |
2169 /* FIXME lto. We should check if T belongs to the | |
2170 file we are writing to. */ | |
2171 if (TREE_CODE (t) == VAR_DECL | |
2172 && TREE_PUBLIC (t) | |
2173 && !DECL_EXTERNAL (t)) | |
2174 TREE_ASM_WRITTEN (t) = 1; | |
2175 } | |
2176 } | 2186 } |
2177 } | 2187 } |
2178 | 2188 |
2179 | 2189 |
2180 /* Write a sequence of indices into the globals vector corresponding | 2190 /* Write a sequence of indices into the globals vector corresponding |
2423 causes the vector of all of the global decls and types used from | 2433 causes the vector of all of the global decls and types used from |
2424 this file to be written in to a section that can then be read in to | 2434 this file to be written in to a section that can then be read in to |
2425 recover these on other side. */ | 2435 recover these on other side. */ |
2426 | 2436 |
2427 static void | 2437 static void |
2428 produce_asm_for_decls (cgraph_node_set set) | 2438 produce_asm_for_decls (cgraph_node_set set, varpool_node_set vset) |
2429 { | 2439 { |
2430 struct lto_out_decl_state *out_state; | 2440 struct lto_out_decl_state *out_state; |
2431 struct lto_out_decl_state *fn_out_state; | 2441 struct lto_out_decl_state *fn_out_state; |
2432 struct lto_decl_header header; | 2442 struct lto_decl_header header; |
2433 char *section_name; | 2443 char *section_name; |
2441 ob->global = true; | 2451 ob->global = true; |
2442 | 2452 |
2443 /* Write out unreferenced globals, alias pairs and labels. We defer | 2453 /* Write out unreferenced globals, alias pairs and labels. We defer |
2444 doing this until now so that we can write out only what is | 2454 doing this until now so that we can write out only what is |
2445 needed. */ | 2455 needed. */ |
2446 output_unreferenced_globals (set); | 2456 output_unreferenced_globals (set, vset); |
2447 | 2457 |
2448 memset (&header, 0, sizeof (struct lto_decl_header)); | 2458 memset (&header, 0, sizeof (struct lto_decl_header)); |
2449 | 2459 |
2450 section_name = lto_get_section_name (LTO_section_decls, NULL); | 2460 section_name = lto_get_section_name (LTO_section_decls, NULL); |
2451 lto_begin_section (section_name, !flag_wpa); | 2461 lto_begin_section (section_name, !flag_wpa); |
2519 | 2529 |
2520 /* Write command line opts. */ | 2530 /* Write command line opts. */ |
2521 lto_write_options (); | 2531 lto_write_options (); |
2522 | 2532 |
2523 /* Deallocate memory and clean up. */ | 2533 /* Deallocate memory and clean up. */ |
2534 for (idx = 0; idx < num_fns; idx++) | |
2535 { | |
2536 fn_out_state = | |
2537 VEC_index (lto_out_decl_state_ptr, lto_function_decl_states, idx); | |
2538 lto_delete_out_decl_state (fn_out_state); | |
2539 } | |
2524 lto_cgraph_encoder_delete (ob->decl_state->cgraph_node_encoder); | 2540 lto_cgraph_encoder_delete (ob->decl_state->cgraph_node_encoder); |
2541 lto_varpool_encoder_delete (ob->decl_state->varpool_node_encoder); | |
2525 VEC_free (lto_out_decl_state_ptr, heap, lto_function_decl_states); | 2542 VEC_free (lto_out_decl_state_ptr, heap, lto_function_decl_states); |
2526 lto_function_decl_states = NULL; | 2543 lto_function_decl_states = NULL; |
2527 destroy_output_block (ob); | 2544 destroy_output_block (ob); |
2528 } | 2545 } |
2529 | 2546 |
2546 0 /* todo_flags_finish */ | 2563 0 /* todo_flags_finish */ |
2547 }, | 2564 }, |
2548 NULL, /* generate_summary */ | 2565 NULL, /* generate_summary */ |
2549 produce_asm_for_decls, /* write_summary */ | 2566 produce_asm_for_decls, /* write_summary */ |
2550 NULL, /* read_summary */ | 2567 NULL, /* read_summary */ |
2551 NULL, /* function_read_summary */ | 2568 produce_asm_for_decls, /* write_optimization_summary */ |
2569 NULL, /* read_optimization_summary */ | |
2552 NULL, /* stmt_fixup */ | 2570 NULL, /* stmt_fixup */ |
2553 0, /* TODOs */ | 2571 0, /* TODOs */ |
2554 NULL, /* function_transform */ | 2572 NULL, /* function_transform */ |
2555 NULL /* variable_transform */ | 2573 NULL /* variable_transform */ |
2556 }; | 2574 }; |