-/* Return the resolution for the decl with index INDEX from DATA_IN. */
-
-static enum ld_plugin_symbol_resolution
-get_resolution (struct data_in *data_in, unsigned index)
-{
- if (data_in->globals_resolution)
- {
- ld_plugin_symbol_resolution_t ret;
- /* We can have references to not emitted functions in
- DECL_FUNCTION_PERSONALITY at least. So we can and have
- to indeed return LDPR_UNKNOWN in some cases. */
- if (VEC_length (ld_plugin_symbol_resolution_t,
- data_in->globals_resolution) <= index)
- return LDPR_UNKNOWN;
- ret = VEC_index (ld_plugin_symbol_resolution_t,
- data_in->globals_resolution,
- index);
- return ret;
- }
- else
- /* Delay resolution finding until decl merging. */
- return LDPR_UNKNOWN;
-}
-
-
-/* Unpack all the non-pointer fields of the TS_BASE structure of
- expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
-{
- /* Note that the code for EXPR has already been unpacked to create EXPR in
- lto_materialize_tree. */
- if (!TYPE_P (expr))
- {
- TREE_SIDE_EFFECTS (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_CONSTANT (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1);
-
- /* TREE_PUBLIC is used on types to indicate that the type
- has a TYPE_CACHED_VALUES vector. This is not streamed out,
- so we skip it here. */
- TREE_PUBLIC (expr) = (unsigned) bp_unpack_value (bp, 1);
- }
- else
- bp_unpack_value (bp, 4);
- TREE_ADDRESSABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_THIS_VOLATILE (expr) = (unsigned) bp_unpack_value (bp, 1);
- if (DECL_P (expr))
- DECL_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
- else if (TYPE_P (expr))
- TYPE_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1);
- else
- bp_unpack_value (bp, 1);
- TREE_ASM_WRITTEN (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_USED (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_PRIVATE (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_PROTECTED (expr) = (unsigned) bp_unpack_value (bp, 1);
- TREE_DEPRECATED (expr) = (unsigned) bp_unpack_value (bp, 1);
- if (TYPE_P (expr))
- TYPE_SATURATING (expr) = (unsigned) bp_unpack_value (bp, 1);
- else if (TREE_CODE (expr) == SSA_NAME)
- SSA_NAME_IS_DEFAULT_DEF (expr) = (unsigned) bp_unpack_value (bp, 1);
- else
- bp_unpack_value (bp, 1);
-}
-
-
-/* Unpack all the non-pointer fields of the TS_REAL_CST structure of
- expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_real_cst_value_fields (struct bitpack_d *bp, tree expr)
-{
- unsigned i;
- REAL_VALUE_TYPE r;
- REAL_VALUE_TYPE *rp;
-
- r.cl = (unsigned) bp_unpack_value (bp, 2);
- r.decimal = (unsigned) bp_unpack_value (bp, 1);
- r.sign = (unsigned) bp_unpack_value (bp, 1);
- r.signalling = (unsigned) bp_unpack_value (bp, 1);
- r.canonical = (unsigned) bp_unpack_value (bp, 1);
- r.uexp = (unsigned) bp_unpack_value (bp, EXP_BITS);
- for (i = 0; i < SIGSZ; i++)
- r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG);
-
- rp = ggc_alloc_real_value ();
- memcpy (rp, &r, sizeof (REAL_VALUE_TYPE));
- TREE_REAL_CST_PTR (expr) = rp;
-}
-
-
-/* Unpack all the non-pointer fields of the TS_FIXED_CST structure of
- expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr)
-{
- struct fixed_value fv;
-
- fv.data.low = (HOST_WIDE_INT) bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT);
- fv.data.high = (HOST_WIDE_INT) bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT);
- fv.mode = (enum machine_mode) bp_unpack_value (bp, HOST_BITS_PER_INT);
- TREE_FIXED_CST (expr) = fv;
-}
-
-
-/* Unpack all the non-pointer fields of the TS_DECL_COMMON structure
- of expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
-{
- DECL_MODE (expr) = (enum machine_mode) bp_unpack_value (bp, 8);
- DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_PRESERVE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_DEBUG_EXPR_IS_FROM (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_EXTERNAL (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_GIMPLE_REG_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_ALIGN (expr) = (unsigned) bp_unpack_value (bp, HOST_BITS_PER_INT);
-
- if (TREE_CODE (expr) == LABEL_DECL)
- {
- DECL_ERROR_ISSUED (expr) = (unsigned) bp_unpack_value (bp, 1);
- EH_LANDING_PAD_NR (expr) = (int) bp_unpack_value (bp, HOST_BITS_PER_INT);
-
- /* Always assume an initial value of -1 for LABEL_DECL_UID to
- force gimple_set_bb to recreate label_to_block_map. */
- LABEL_DECL_UID (expr) = -1;
- }
-
- if (TREE_CODE (expr) == FIELD_DECL)
- {
- unsigned HOST_WIDE_INT off_align;
- DECL_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_NONADDRESSABLE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- off_align = (unsigned HOST_WIDE_INT) bp_unpack_value (bp, 8);
- SET_DECL_OFFSET_ALIGN (expr, off_align);
- }
-
- if (TREE_CODE (expr) == RESULT_DECL
- || TREE_CODE (expr) == PARM_DECL
- || TREE_CODE (expr) == VAR_DECL)
- {
- DECL_BY_REFERENCE (expr) = (unsigned) bp_unpack_value (bp, 1);
- if (TREE_CODE (expr) == VAR_DECL
- || TREE_CODE (expr) == PARM_DECL)
- DECL_HAS_VALUE_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_RESTRICTED_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- }
-}
-
-
-/* Unpack all the non-pointer fields of the TS_DECL_WRTL structure
- of expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_decl_wrtl_value_fields (struct bitpack_d *bp, tree expr)
-{
- DECL_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
-}
-
-
-/* Unpack all the non-pointer fields of the TS_DECL_WITH_VIS structure
- of expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_decl_with_vis_value_fields (struct bitpack_d *bp, tree expr)
-{
- DECL_DEFER_OUTPUT (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_COMMON (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_DLLIMPORT_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_WEAK (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_SEEN_IN_BIND_EXPR_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_COMDAT (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_VISIBILITY (expr) = (enum symbol_visibility) bp_unpack_value (bp, 2);
- DECL_VISIBILITY_SPECIFIED (expr) = (unsigned) bp_unpack_value (bp, 1);
-
- if (TREE_CODE (expr) == VAR_DECL)
- {
- DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_IN_TEXT_SECTION (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_IN_CONSTANT_POOL (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_TLS_MODEL (expr) = (enum tls_model) bp_unpack_value (bp, 3);
- }
-
- if (VAR_OR_FUNCTION_DECL_P (expr))
- {
- priority_type p;
- p = (priority_type) bp_unpack_value (bp, HOST_BITS_PER_SHORT);
- SET_DECL_INIT_PRIORITY (expr, p);
- }
-}
-
-
-/* Unpack all the non-pointer fields of the TS_FUNCTION_DECL structure
- of expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_function_decl_value_fields (struct bitpack_d *bp, tree expr)
-{
- DECL_FUNCTION_CODE (expr) = (enum built_in_function) bp_unpack_value (bp, 11);
- DECL_BUILT_IN_CLASS (expr) = (enum built_in_class) bp_unpack_value (bp, 2);
- DECL_STATIC_CONSTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_STATIC_DESTRUCTOR (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_UNINLINABLE (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_POSSIBLY_INLINED (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_IS_NOVOPS (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_IS_RETURNS_TWICE (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_IS_MALLOC (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_IS_OPERATOR_NEW (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_DECLARED_INLINE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_STATIC_CHAIN (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_NO_INLINE_WARNING_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (expr)
- = (unsigned) bp_unpack_value (bp, 1);
- DECL_NO_LIMIT_STACK (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
- DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1);
-}
-
-
-/* Unpack all the non-pointer fields of the TS_TYPE structure
- of expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_type_value_fields (struct bitpack_d *bp, tree expr)
-{
- enum machine_mode mode;
-
- TYPE_PRECISION (expr) = (unsigned) bp_unpack_value (bp, 10);
- mode = (enum machine_mode) bp_unpack_value (bp, 8);
- SET_TYPE_MODE (expr, mode);
- TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1);
- TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1);
- TYPE_NEEDS_CONSTRUCTING (expr) = (unsigned) bp_unpack_value (bp, 1);
- if (RECORD_OR_UNION_TYPE_P (expr))
- TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
- TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
- TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1);
- TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr)
- = (unsigned) bp_unpack_value (bp, 2);
- TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1);
- TYPE_READONLY (expr) = (unsigned) bp_unpack_value (bp, 1);
- TYPE_ALIGN (expr) = (unsigned) bp_unpack_value (bp, HOST_BITS_PER_INT);
- TYPE_ALIAS_SET (expr) = bp_unpack_value (bp, HOST_BITS_PER_INT);
-}
-
-
-/* Unpack all the non-pointer fields of the TS_BLOCK structure
- of expression EXPR from bitpack BP. */
-
-static void
-unpack_ts_block_value_fields (struct bitpack_d *bp, tree expr)
-{
- BLOCK_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1);
- BLOCK_NUMBER (expr) = (unsigned) bp_unpack_value (bp, 31);
-}
-
-
-/* Unpack all the non-pointer fields in EXPR into a bit pack. */
-
-static void
-unpack_value_fields (struct bitpack_d *bp, tree expr)
-{
- enum tree_code code;
-
- code = TREE_CODE (expr);
-
- /* Note that all these functions are highly sensitive to changes in
- the types and sizes of each of the fields being packed. */
- unpack_ts_base_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
- unpack_ts_real_cst_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_FIXED_CST))
- unpack_ts_fixed_cst_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
- unpack_ts_decl_common_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_DECL_WRTL))
- unpack_ts_decl_wrtl_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
- unpack_ts_decl_with_vis_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
- unpack_ts_function_decl_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_TYPE))
- unpack_ts_type_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
- unpack_ts_block_value_fields (bp, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_SSA_NAME))
- {
- /* We only stream the version number of SSA names. */
- gcc_unreachable ();
- }
-
- if (CODE_CONTAINS_STRUCT (code, TS_STATEMENT_LIST))
- {
- /* This is only used by GENERIC. */
- gcc_unreachable ();
- }
-
- if (CODE_CONTAINS_STRUCT (code, TS_OMP_CLAUSE))
- {
- /* This is only used by High GIMPLE. */
- gcc_unreachable ();
- }
-}
-
-
-/* Materialize a new tree from input block IB using descriptors in
- DATA_IN. The code for the new tree should match TAG. Store in
- *IX_P the index into the reader cache where the new tree is stored. */
-
-static tree
-lto_materialize_tree (struct lto_input_block *ib, struct data_in *data_in,
- enum LTO_tags tag, int *ix_p)
-{
- struct bitpack_d bp;
- enum tree_code code;
- tree result;
-#ifdef LTO_STREAMER_DEBUG
- HOST_WIDEST_INT orig_address_in_writer;
-#endif
- HOST_WIDE_INT ix;
-
- result = NULL_TREE;
-
- /* Read the header of the node we are about to create. */
- ix = lto_input_sleb128 (ib);
- gcc_assert ((int) ix == ix);
- *ix_p = (int) ix;
-
-#ifdef LTO_STREAMER_DEBUG
- /* Read the word representing the memory address for the tree
- as it was written by the writer. This is useful when
- debugging differences between the writer and reader. */
- orig_address_in_writer = lto_input_sleb128 (ib);
- gcc_assert ((intptr_t) orig_address_in_writer == orig_address_in_writer);
-#endif
-
- code = lto_tag_to_tree_code (tag);
-
- /* We should never see an SSA_NAME tree. Only the version numbers of
- SSA names are ever written out. See input_ssa_names. */
- gcc_assert (code != SSA_NAME);
-
- /* Instantiate a new tree using the header data. */
- if (CODE_CONTAINS_STRUCT (code, TS_STRING))
- result = input_string_cst (data_in, ib);
- else if (CODE_CONTAINS_STRUCT (code, TS_IDENTIFIER))
- result = input_identifier (data_in, ib);
- else if (CODE_CONTAINS_STRUCT (code, TS_VEC))
- {
- HOST_WIDE_INT len = lto_input_sleb128 (ib);
- result = make_tree_vec (len);
- }
- else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
- {
- unsigned HOST_WIDE_INT len = lto_input_uleb128 (ib);
- result = make_tree_binfo (len);
- }
- else
- {
- /* All other nodes can be materialized with a raw make_node
- call. */
- result = make_node (code);
- }
-
-#ifdef LTO_STREAMER_DEBUG
- /* Store the original address of the tree as seen by the writer
- in RESULT's aux field. This is useful when debugging streaming
- problems. This way, a debugging session can be started on
- both writer and reader with a breakpoint using this address
- value in both. */
- lto_orig_address_map (result, (intptr_t) orig_address_in_writer);
-#endif
-
- /* Read the bitpack of non-pointer values from IB. */
- bp = lto_input_bitpack (ib);
-
- /* The first word in BP contains the code of the tree that we
- are about to read. */
- code = (enum tree_code) bp_unpack_value (&bp, 16);
- lto_tag_check (lto_tree_code_to_tag (code), tag);
-
- /* Unpack all the value fields from BP. */
- unpack_value_fields (&bp, result);
-
- /* Enter RESULT in the reader cache. This will make RESULT
- available so that circular references in the rest of the tree
- structure can be resolved in subsequent calls to lto_input_tree. */
- lto_streamer_cache_insert_at (data_in->reader_cache, result, ix);
-
- return result;
-}
-
-
-/* Read a chain of tree nodes from input block IB. DATA_IN contains
- tables and descriptors for the file being read. */
-
-static tree
-lto_input_chain (struct lto_input_block *ib, struct data_in *data_in)
-{
- int i, count;
- tree first, prev, curr;
-
- first = prev = NULL_TREE;
- count = lto_input_sleb128 (ib);
- for (i = 0; i < count; i++)
- {
- curr = lto_input_tree (ib, data_in);
- if (prev)
- TREE_CHAIN (prev) = curr;
- else
- first = curr;
-
- TREE_CHAIN (curr) = NULL_TREE;
- prev = curr;
- }
-
- return first;
-}
-
-
-/* Read all pointer fields in the TS_COMMON structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-
-static void
-lto_input_ts_common_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- TREE_TYPE (expr) = lto_input_tree (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_VECTOR structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_vector_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- TREE_VECTOR_CST_ELTS (expr) = lto_input_chain (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_COMPLEX structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_complex_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- TREE_REALPART (expr) = lto_input_tree (ib, data_in);
- TREE_IMAGPART (expr) = lto_input_tree (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_DECL_MINIMAL structure of EXPR
- from input block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_decl_minimal_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- DECL_NAME (expr) = lto_input_tree (ib, data_in);
- DECL_CONTEXT (expr) = lto_input_tree (ib, data_in);
- DECL_SOURCE_LOCATION (expr) = lto_input_location (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_DECL_COMMON structure of EXPR from
- input block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_decl_common_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- DECL_SIZE (expr) = lto_input_tree (ib, data_in);
- DECL_SIZE_UNIT (expr) = lto_input_tree (ib, data_in);
-
- if (TREE_CODE (expr) != FUNCTION_DECL)
- DECL_INITIAL (expr) = lto_input_tree (ib, data_in);
-
- DECL_ATTRIBUTES (expr) = lto_input_tree (ib, data_in);
- DECL_ABSTRACT_ORIGIN (expr) = lto_input_tree (ib, data_in);
-
- if (TREE_CODE (expr) == PARM_DECL)
- TREE_CHAIN (expr) = lto_input_chain (ib, data_in);
-
- if ((TREE_CODE (expr) == VAR_DECL
- || TREE_CODE (expr) == PARM_DECL)
- && DECL_HAS_VALUE_EXPR_P (expr))
- SET_DECL_VALUE_EXPR (expr, lto_input_tree (ib, data_in));
-}
-
-
-/* Read all pointer fields in the TS_DECL_NON_COMMON structure of
- EXPR from input block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_decl_non_common_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- if (TREE_CODE (expr) == FUNCTION_DECL)
- {
- DECL_ARGUMENTS (expr) = lto_input_tree (ib, data_in);
- DECL_RESULT (expr) = lto_input_tree (ib, data_in);
- }
- DECL_VINDEX (expr) = lto_input_tree (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_DECL_WITH_VIS structure of EXPR
- from input block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_decl_with_vis_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- tree id;
-
- id = lto_input_tree (ib, data_in);
- if (id)
- {
- gcc_assert (TREE_CODE (id) == IDENTIFIER_NODE);
- SET_DECL_ASSEMBLER_NAME (expr, id);
- }
-
- DECL_SECTION_NAME (expr) = lto_input_tree (ib, data_in);
- DECL_COMDAT_GROUP (expr) = lto_input_tree (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_FIELD_DECL structure of EXPR from
- input block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_field_decl_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- DECL_FIELD_OFFSET (expr) = lto_input_tree (ib, data_in);
- DECL_BIT_FIELD_TYPE (expr) = lto_input_tree (ib, data_in);
- DECL_QUALIFIER (expr) = lto_input_tree (ib, data_in);
- DECL_FIELD_BIT_OFFSET (expr) = lto_input_tree (ib, data_in);
- DECL_FCONTEXT (expr) = lto_input_tree (ib, data_in);
- TREE_CHAIN (expr) = lto_input_chain (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_FUNCTION_DECL structure of EXPR
- from input block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_function_decl_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- /* DECL_STRUCT_FUNCTION is handled by lto_input_function. FIXME lto,
- maybe it should be handled here? */
- DECL_FUNCTION_PERSONALITY (expr) = lto_input_tree (ib, data_in);
- DECL_FUNCTION_SPECIFIC_TARGET (expr) = lto_input_tree (ib, data_in);
- DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = lto_input_tree (ib, data_in);
-
- /* If the file contains a function with an EH personality set,
- then it was compiled with -fexceptions. In that case, initialize
- the backend EH machinery. */
- if (DECL_FUNCTION_PERSONALITY (expr))
- lto_init_eh ();
-}
-
-
-/* Read all pointer fields in the TS_TYPE structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_type_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- if (TREE_CODE (expr) == ENUMERAL_TYPE)
- TYPE_VALUES (expr) = lto_input_tree (ib, data_in);
- else if (TREE_CODE (expr) == ARRAY_TYPE)
- TYPE_DOMAIN (expr) = lto_input_tree (ib, data_in);
- else if (RECORD_OR_UNION_TYPE_P (expr))
- TYPE_FIELDS (expr) = lto_input_tree (ib, data_in);
- else if (TREE_CODE (expr) == FUNCTION_TYPE
- || TREE_CODE (expr) == METHOD_TYPE)
- TYPE_ARG_TYPES (expr) = lto_input_tree (ib, data_in);
- else if (TREE_CODE (expr) == VECTOR_TYPE)
- TYPE_DEBUG_REPRESENTATION_TYPE (expr) = lto_input_tree (ib, data_in);
-
- TYPE_SIZE (expr) = lto_input_tree (ib, data_in);
- TYPE_SIZE_UNIT (expr) = lto_input_tree (ib, data_in);
- TYPE_ATTRIBUTES (expr) = lto_input_tree (ib, data_in);
- TYPE_NAME (expr) = lto_input_tree (ib, data_in);
- /* Do not stream TYPE_POINTER_TO or TYPE_REFERENCE_TO nor
- TYPE_NEXT_PTR_TO or TYPE_NEXT_REF_TO. */
- if (!POINTER_TYPE_P (expr))
- TYPE_MINVAL (expr) = lto_input_tree (ib, data_in);
- TYPE_MAXVAL (expr) = lto_input_tree (ib, data_in);
- TYPE_MAIN_VARIANT (expr) = lto_input_tree (ib, data_in);
- /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists
- during fixup. */
- if (RECORD_OR_UNION_TYPE_P (expr))
- TYPE_BINFO (expr) = lto_input_tree (ib, data_in);
- TYPE_CONTEXT (expr) = lto_input_tree (ib, data_in);
- /* TYPE_CANONICAL gets re-computed during type merging. */
- TYPE_CANONICAL (expr) = NULL_TREE;
- TYPE_STUB_DECL (expr) = lto_input_tree (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_LIST structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_list_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- TREE_PURPOSE (expr) = lto_input_tree (ib, data_in);
- TREE_VALUE (expr) = lto_input_tree (ib, data_in);
- TREE_CHAIN (expr) = lto_input_chain (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_VEC structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_vec_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- int i;
-
- /* Note that TREE_VEC_LENGTH was read by lto_materialize_tree to
- instantiate EXPR. */
- for (i = 0; i < TREE_VEC_LENGTH (expr); i++)
- TREE_VEC_ELT (expr, i) = lto_input_tree (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_EXP structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-
-static void
-lto_input_ts_exp_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- int i, length;
- location_t loc;
-
- length = lto_input_sleb128 (ib);
- gcc_assert (length == TREE_OPERAND_LENGTH (expr));
-
- for (i = 0; i < length; i++)
- TREE_OPERAND (expr, i) = lto_input_tree (ib, data_in);
-
- loc = lto_input_location (ib, data_in);
- SET_EXPR_LOCATION (expr, loc);
- TREE_BLOCK (expr) = lto_input_tree (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_BLOCK structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_block_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- unsigned i, len;
-
- BLOCK_SOURCE_LOCATION (expr) = lto_input_location (ib, data_in);
- BLOCK_VARS (expr) = lto_input_chain (ib, data_in);
-
- len = lto_input_uleb128 (ib);
- for (i = 0; i < len; i++)
- {
- tree t = lto_input_tree (ib, data_in);
- VEC_safe_push (tree, gc, BLOCK_NONLOCALIZED_VARS (expr), t);
- }
-
- BLOCK_SUPERCONTEXT (expr) = lto_input_tree (ib, data_in);
- BLOCK_ABSTRACT_ORIGIN (expr) = lto_input_tree (ib, data_in);
- BLOCK_FRAGMENT_ORIGIN (expr) = lto_input_tree (ib, data_in);
- BLOCK_FRAGMENT_CHAIN (expr) = lto_input_tree (ib, data_in);
- BLOCK_SUBBLOCKS (expr) = lto_input_chain (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_BINFO structure of EXPR from input
- block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_binfo_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- unsigned i, len;
- tree t;
-
- /* Note that the number of slots in EXPR was read in
- lto_materialize_tree when instantiating EXPR. However, the
- vector is empty so we cannot rely on VEC_length to know how many
- elements to read. So, this list is emitted as a 0-terminated
- list on the writer side. */
- do
- {
- t = lto_input_tree (ib, data_in);
- if (t)
- VEC_quick_push (tree, BINFO_BASE_BINFOS (expr), t);
- }
- while (t);
-
- BINFO_OFFSET (expr) = lto_input_tree (ib, data_in);
- BINFO_VTABLE (expr) = lto_input_tree (ib, data_in);
- BINFO_VIRTUALS (expr) = lto_input_tree (ib, data_in);
- BINFO_VPTR_FIELD (expr) = lto_input_tree (ib, data_in);
-
- len = lto_input_uleb128 (ib);
- for (i = 0; i < len; i++)
- {
- tree a = lto_input_tree (ib, data_in);
- VEC_safe_push (tree, gc, BINFO_BASE_ACCESSES (expr), a);
- }
-
- BINFO_INHERITANCE_CHAIN (expr) = lto_input_tree (ib, data_in);
- BINFO_SUBVTT_INDEX (expr) = lto_input_tree (ib, data_in);
- BINFO_VPTR_INDEX (expr) = lto_input_tree (ib, data_in);
-}
-
-
-/* Read all pointer fields in the TS_CONSTRUCTOR structure of EXPR from
- input block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_ts_constructor_tree_pointers (struct lto_input_block *ib,
- struct data_in *data_in, tree expr)
-{
- unsigned i, len;
-
- len = lto_input_uleb128 (ib);
- for (i = 0; i < len; i++)
- {
- tree index, value;
-
- index = lto_input_tree (ib, data_in);
- value = lto_input_tree (ib, data_in);
- CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (expr), index, value);
- }
-}
-
-
-/* Helper for lto_input_tree. Read all pointer fields in EXPR from
- input block IB. DATA_IN contains tables and descriptors for the
- file being read. */
-
-static void
-lto_input_tree_pointers (struct lto_input_block *ib, struct data_in *data_in,
- tree expr)
-{
- enum tree_code code;
-
- code = TREE_CODE (expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
- lto_input_ts_common_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
- lto_input_ts_vector_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX))
- lto_input_ts_complex_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_DECL_MINIMAL))
- lto_input_ts_decl_minimal_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
- lto_input_ts_decl_common_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
- lto_input_ts_decl_non_common_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
- lto_input_ts_decl_with_vis_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
- lto_input_ts_field_decl_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
- lto_input_ts_function_decl_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_TYPE))
- lto_input_ts_type_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_LIST))
- lto_input_ts_list_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_VEC))
- lto_input_ts_vec_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_EXP))
- lto_input_ts_exp_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_SSA_NAME))
- {
- /* We only stream the version number of SSA names. */
- gcc_unreachable ();
- }
-
- if (CODE_CONTAINS_STRUCT (code, TS_BLOCK))
- lto_input_ts_block_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
- lto_input_ts_binfo_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_STATEMENT_LIST))
- {
- /* This should only appear in GENERIC. */
- gcc_unreachable ();
- }
-
- if (CODE_CONTAINS_STRUCT (code, TS_CONSTRUCTOR))
- lto_input_ts_constructor_tree_pointers (ib, data_in, expr);
-
- if (CODE_CONTAINS_STRUCT (code, TS_OMP_CLAUSE))
- {
- /* This should only appear in High GIMPLE. */
- gcc_unreachable ();
- }
-
- if (CODE_CONTAINS_STRUCT (code, TS_OPTIMIZATION))
- {
- sorry ("optimization options not supported yet");
- }
-
- if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION))
- {
- sorry ("target optimization options not supported yet");
- }
-}
-
-
-/* Register DECL with the global symbol table and change its
- name if necessary to avoid name clashes for static globals across
- different files. */
-
-static void
-lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl)
-{
- /* Register symbols with file or global scope to mark what input
- file has their definition. */
- if (decl_function_context (decl) == NULL_TREE)
- {
- /* Variable has file scope, not local. Need to ensure static variables
- between different files don't clash unexpectedly. */
- if (!TREE_PUBLIC (decl))
- {
- /* ??? We normally pre-mangle names before we serialize them
- out. Here, in lto1, we do not know the language, and
- thus cannot do the mangling again. Instead, we just
- append a suffix to the mangled name. The resulting name,
- however, is not a properly-formed mangled name, and will
- confuse any attempt to unmangle it. */
- const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
- char *label;
-
- ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
- SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
- rest_of_decl_compilation (decl, 1, 0);
- }
- }
-
- /* If this variable has already been declared, queue the
- declaration for merging. */
- if (TREE_PUBLIC (decl))
- {
- int ix;
- if (!lto_streamer_cache_lookup (data_in->reader_cache, decl, &ix))
- gcc_unreachable ();
- lto_symtab_register_decl (decl, get_resolution (data_in, ix),
- data_in->file_data);
- }
-}
-
-
-
-/* Register DECL with the global symbol table and change its
- name if necessary to avoid name clashes for static globals across
- different files. DATA_IN contains descriptors and tables for the
- file being read. */
-
-static void
-lto_register_function_decl_in_symtab (struct data_in *data_in, tree decl)
-{
- /* Need to ensure static entities between different files
- don't clash unexpectedly. */
- if (!TREE_PUBLIC (decl))
- {
- /* We must not use the DECL_ASSEMBLER_NAME macro here, as it
- may set the assembler name where it was previously empty. */
- tree old_assembler_name = decl->decl_with_vis.assembler_name;
-
- /* FIXME lto: We normally pre-mangle names before we serialize
- them out. Here, in lto1, we do not know the language, and
- thus cannot do the mangling again. Instead, we just append a
- suffix to the mangled name. The resulting name, however, is
- not a properly-formed mangled name, and will confuse any
- attempt to unmangle it. */
- const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
- char *label;
-
- ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
- SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
-
- /* We may arrive here with the old assembler name not set
- if the function body is not needed, e.g., it has been
- inlined away and does not appear in the cgraph. */
- if (old_assembler_name)
- {
- tree new_assembler_name = DECL_ASSEMBLER_NAME (decl);
-
- /* Make the original assembler name available for later use.
- We may have used it to indicate the section within its
- object file where the function body may be found.
- FIXME lto: Find a better way to maintain the function decl
- to body section mapping so we don't need this hack. */
- lto_record_renamed_decl (data_in->file_data,
- IDENTIFIER_POINTER (old_assembler_name),
- IDENTIFIER_POINTER (new_assembler_name));
-
- /* Also register the reverse mapping so that we can find the
- new name given to an existing assembler name (used when
- restoring alias pairs in input_constructors_or_inits. */
- lto_record_renamed_decl (data_in->file_data,
- IDENTIFIER_POINTER (new_assembler_name),
- IDENTIFIER_POINTER (old_assembler_name));
- }
- }
-
- /* If this variable has already been declared, queue the
- declaration for merging. */
- if (TREE_PUBLIC (decl) && !DECL_ABSTRACT (decl))
- {
- int ix;
- if (!lto_streamer_cache_lookup (data_in->reader_cache, decl, &ix))
- gcc_unreachable ();
- lto_symtab_register_decl (decl, get_resolution (data_in, ix),
- data_in->file_data);
- }
-}
-
-
-/* Read an index IX from input block IB and return the tree node at
- DATA_IN->FILE_DATA->GLOBALS_INDEX[IX]. */
-
-static tree
-lto_get_pickled_tree (struct lto_input_block *ib, struct data_in *data_in)
-{
- HOST_WIDE_INT ix;
- tree result;
- enum LTO_tags expected_tag;
- unsigned HOST_WIDE_INT orig_offset;
-
- ix = lto_input_sleb128 (ib);
- expected_tag = (enum LTO_tags) lto_input_uleb128 (ib);
-
- orig_offset = lto_input_uleb128 (ib);
- gcc_assert (orig_offset == (unsigned) orig_offset);
-
- result = lto_streamer_cache_get (data_in->reader_cache, ix);
- if (result == NULL_TREE)
- {
- /* We have not yet read the cache slot IX. Go to the offset
- in the stream where the physical tree node is, and materialize
- it from there. */
- struct lto_input_block fwd_ib;
-
- /* If we are trying to go back in the stream, something is wrong.
- We should've read the node at the earlier position already. */
- if (ib->p >= orig_offset)
- internal_error ("bytecode stream: tried to jump backwards in the "
- "stream");
-
- LTO_INIT_INPUT_BLOCK (fwd_ib, ib->data, orig_offset, ib->len);
- result = lto_input_tree (&fwd_ib, data_in);
- }
-
- gcc_assert (result
- && TREE_CODE (result) == lto_tag_to_tree_code (expected_tag));
-
- return result;
-}
-
-
-/* Read a code and class from input block IB and return the
- corresponding builtin. DATA_IN is as in lto_input_tree. */
-
-static tree
-lto_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
-{
- enum built_in_class fclass;
- enum built_in_function fcode;
- const char *asmname;
- tree result;
- int ix;
-
- fclass = (enum built_in_class) lto_input_uleb128 (ib);
- gcc_assert (fclass == BUILT_IN_NORMAL || fclass == BUILT_IN_MD);
-
- fcode = (enum built_in_function) lto_input_uleb128 (ib);
-
- ix = lto_input_sleb128 (ib);
- gcc_assert (ix == (int) ix);
-
- if (fclass == BUILT_IN_NORMAL)
- {
- gcc_assert (fcode < END_BUILTINS);
- result = built_in_decls[fcode];
- gcc_assert (result);
- }
- else if (fclass == BUILT_IN_MD)
- {
- result = targetm.builtin_decl (fcode, true);
- if (!result || result == error_mark_node)
- fatal_error ("target specific builtin not available");
- }
- else
- gcc_unreachable ();
-
- asmname = input_string (data_in, ib);
- if (asmname)
- set_builtin_user_assembler_name (result, asmname);
-
- lto_streamer_cache_insert_at (data_in->reader_cache, result, ix);
-
- return result;
-}
-
-