1 /* Read the GIMPLE representation from a file stream.
3 Copyright (C) 2009-2015 Free Software Foundation, Inc.
4 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
5 Re-implemented by Diego Novillo <dnovillo@google.com>
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3. If not see
21 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
31 #include "fold-const.h"
32 #include "stringpool.h"
33 #include "hard-reg-set.h"
37 #include "insn-config.h"
48 #include "dominance.h"
50 #include "basic-block.h"
51 #include "tree-ssa-alias.h"
52 #include "internal-fn.h"
53 #include "gimple-expr.h"
55 #include "gimple-iterator.h"
56 #include "gimple-ssa.h"
58 #include "tree-ssanames.h"
59 #include "tree-into-ssa.h"
62 #include "tree-pass.h"
63 #include "diagnostic.h"
67 #include "ipa-utils.h"
68 #include "data-streamer.h"
69 #include "gimple-streamer.h"
70 #include "lto-streamer.h"
71 #include "tree-streamer.h"
72 #include "streamer-hooks.h"
76 struct freeing_string_slot_hasher
: string_slot_hasher
78 static inline void remove (value_type
*);
82 freeing_string_slot_hasher::remove (value_type
*v
)
87 /* The table to hold the file names. */
88 static hash_table
<freeing_string_slot_hasher
> *file_name_hash_table
;
91 /* Check that tag ACTUAL has one of the given values. NUM_TAGS is the
92 number of valid tag values to check. */
95 lto_tag_check_set (enum LTO_tags actual
, int ntags
, ...)
100 va_start (ap
, ntags
);
101 for (i
= 0; i
< ntags
; i
++)
102 if ((unsigned) actual
== va_arg (ap
, unsigned))
109 internal_error ("bytecode stream: unexpected tag %s", lto_tag_name (actual
));
113 /* Read LENGTH bytes from STREAM to ADDR. */
116 lto_input_data_block (struct lto_input_block
*ib
, void *addr
, size_t length
)
119 unsigned char *const buffer
= (unsigned char *const) addr
;
121 for (i
= 0; i
< length
; i
++)
122 buffer
[i
] = streamer_read_uchar (ib
);
126 /* Lookup STRING in file_name_hash_table. If found, return the existing
127 string, otherwise insert STRING as the canonical version. */
130 canon_file_name (const char *string
)
133 struct string_slot s_slot
;
134 size_t len
= strlen (string
);
139 slot
= file_name_hash_table
->find_slot (&s_slot
, INSERT
);
143 struct string_slot
*new_slot
;
145 saved_string
= (char *) xmalloc (len
+ 1);
146 new_slot
= XCNEW (struct string_slot
);
147 memcpy (saved_string
, string
, len
+ 1);
148 new_slot
->s
= saved_string
;
155 struct string_slot
*old_slot
= *slot
;
160 /* Pointer to currently alive instance of lto_location_cache. */
162 lto_location_cache
*lto_location_cache::current_cache
;
164 /* Sort locations in source order. Start with file from last application. */
167 lto_location_cache::cmp_loc (const void *pa
, const void *pb
)
169 const cached_location
*a
= ((const cached_location
*)pa
);
170 const cached_location
*b
= ((const cached_location
*)pb
);
171 const char *current_file
= current_cache
->current_file
;
172 int current_line
= current_cache
->current_line
;
174 if (a
->file
== current_file
&& b
->file
!= current_file
)
176 if (a
->file
!= current_file
&& b
->file
== current_file
)
178 if (a
->file
== current_file
&& b
->file
== current_file
)
180 if (a
->line
== current_line
&& b
->line
!= current_line
)
182 if (a
->line
!= current_line
&& b
->line
== current_line
)
185 if (a
->file
!= b
->file
)
186 return strcmp (a
->file
, b
->file
);
187 if (a
->line
!= b
->line
)
188 return a
->line
- b
->line
;
189 return a
->col
- b
->col
;
192 /* Apply all changes in location cache. Add locations into linemap and patch
196 lto_location_cache::apply_location_cache ()
198 static const char *prev_file
;
199 if (!loc_cache
.length ())
201 if (loc_cache
.length () > 1)
202 loc_cache
.qsort (cmp_loc
);
204 for (unsigned int i
= 0; i
< loc_cache
.length (); i
++)
206 struct cached_location loc
= loc_cache
[i
];
208 if (current_file
!= loc
.file
)
209 linemap_add (line_table
, prev_file
? LC_RENAME
: LC_ENTER
,
210 false, loc
.file
, loc
.line
);
211 else if (current_line
!= loc
.line
)
215 for (unsigned int j
= i
+ 1; j
< loc_cache
.length (); j
++)
216 if (loc
.file
!= loc_cache
[j
].file
217 || loc
.line
!= loc_cache
[j
].line
)
219 else if (max
< loc_cache
[j
].col
)
220 max
= loc_cache
[j
].col
;
221 linemap_line_start (line_table
, loc
.line
, max
+ 1);
223 gcc_assert (*loc
.loc
== BUILTINS_LOCATION
+ 1);
224 if (current_file
== loc
.file
&& current_line
== loc
.line
225 && current_col
== loc
.col
)
226 *loc
.loc
= current_loc
;
228 current_loc
= *loc
.loc
= linemap_position_for_column (line_table
,
230 current_line
= loc
.line
;
231 prev_file
= current_file
= loc
.file
;
232 current_col
= loc
.col
;
234 loc_cache
.truncate (0);
239 /* Tree merging did not suceed; mark all changes in the cache as accepted. */
242 lto_location_cache::accept_location_cache ()
244 gcc_assert (current_cache
== this);
245 accepted_length
= loc_cache
.length ();
248 /* Tree merging did suceed; throw away recent changes. */
251 lto_location_cache::revert_location_cache ()
253 loc_cache
.truncate (accepted_length
);
256 /* Read a location bitpack from input block IB and either update *LOC directly
257 or add it to the location cache.
258 It is neccesary to call apply_location_cache to get *LOC updated. */
261 lto_location_cache::input_location (location_t
*loc
, struct bitpack_d
*bp
,
262 struct data_in
*data_in
)
264 static const char *stream_file
;
265 static int stream_line
;
266 static int stream_col
;
267 bool file_change
, line_change
, column_change
;
269 gcc_assert (current_cache
== this);
271 *loc
= bp_unpack_int_in_range (bp
, "location", 0, RESERVED_LOCATION_COUNT
);
273 if (*loc
< RESERVED_LOCATION_COUNT
)
276 /* Keep value RESERVED_LOCATION_COUNT in *loc as linemap lookups will
279 file_change
= bp_unpack_value (bp
, 1);
280 line_change
= bp_unpack_value (bp
, 1);
281 column_change
= bp_unpack_value (bp
, 1);
284 stream_file
= canon_file_name (bp_unpack_string (data_in
, bp
));
287 stream_line
= bp_unpack_var_len_unsigned (bp
);
290 stream_col
= bp_unpack_var_len_unsigned (bp
);
292 /* This optimization saves location cache operations druing gimple
295 if (current_file
== stream_file
&& current_line
== stream_line
296 && current_col
== stream_col
)
302 struct cached_location entry
= {stream_file
, loc
, stream_line
, stream_col
};
303 loc_cache
.safe_push (entry
);
306 /* Read a location bitpack from input block IB and either update *LOC directly
307 or add it to the location cache.
308 It is neccesary to call apply_location_cache to get *LOC updated. */
311 lto_input_location (location_t
*loc
, struct bitpack_d
*bp
,
312 struct data_in
*data_in
)
314 data_in
->location_cache
.input_location (loc
, bp
, data_in
);
317 /* Read location and return it instead of going through location caching.
318 This should be used only when the resulting location is not going to be
322 stream_input_location_now (struct bitpack_d
*bp
, struct data_in
*data_in
)
325 stream_input_location (&loc
, bp
, data_in
);
326 data_in
->location_cache
.apply_location_cache ();
330 /* Read a reference to a tree node from DATA_IN using input block IB.
331 TAG is the expected node that should be found in IB, if TAG belongs
332 to one of the indexable trees, expect to read a reference index to
333 be looked up in one of the symbol tables, otherwise read the pysical
334 representation of the tree using stream_read_tree. FN is the
335 function scope for the read tree. */
338 lto_input_tree_ref (struct lto_input_block
*ib
, struct data_in
*data_in
,
339 struct function
*fn
, enum LTO_tags tag
)
341 unsigned HOST_WIDE_INT ix_u
;
342 tree result
= NULL_TREE
;
344 lto_tag_check_range (tag
, LTO_field_decl_ref
, LTO_namelist_decl_ref
);
349 ix_u
= streamer_read_uhwi (ib
);
350 result
= lto_file_decl_data_get_type (data_in
->file_data
, ix_u
);
353 case LTO_ssa_name_ref
:
354 ix_u
= streamer_read_uhwi (ib
);
355 result
= (*SSANAMES (fn
))[ix_u
];
358 case LTO_field_decl_ref
:
359 ix_u
= streamer_read_uhwi (ib
);
360 result
= lto_file_decl_data_get_field_decl (data_in
->file_data
, ix_u
);
363 case LTO_function_decl_ref
:
364 ix_u
= streamer_read_uhwi (ib
);
365 result
= lto_file_decl_data_get_fn_decl (data_in
->file_data
, ix_u
);
368 case LTO_type_decl_ref
:
369 ix_u
= streamer_read_uhwi (ib
);
370 result
= lto_file_decl_data_get_type_decl (data_in
->file_data
, ix_u
);
373 case LTO_namespace_decl_ref
:
374 ix_u
= streamer_read_uhwi (ib
);
375 result
= lto_file_decl_data_get_namespace_decl (data_in
->file_data
, ix_u
);
378 case LTO_global_decl_ref
:
379 case LTO_result_decl_ref
:
380 case LTO_const_decl_ref
:
381 case LTO_imported_decl_ref
:
382 case LTO_label_decl_ref
:
383 case LTO_translation_unit_decl_ref
:
384 case LTO_namelist_decl_ref
:
385 ix_u
= streamer_read_uhwi (ib
);
386 result
= lto_file_decl_data_get_var_decl (data_in
->file_data
, ix_u
);
399 /* Read and return a double-linked list of catch handlers from input
400 block IB, using descriptors in DATA_IN. */
402 static struct eh_catch_d
*
403 lto_input_eh_catch_list (struct lto_input_block
*ib
, struct data_in
*data_in
,
409 *last_p
= first
= NULL
;
410 tag
= streamer_read_record_start (ib
);
416 lto_tag_check_range (tag
, LTO_eh_catch
, LTO_eh_catch
);
418 /* Read the catch node. */
419 n
= ggc_cleared_alloc
<eh_catch_d
> ();
420 n
->type_list
= stream_read_tree (ib
, data_in
);
421 n
->filter_list
= stream_read_tree (ib
, data_in
);
422 n
->label
= stream_read_tree (ib
, data_in
);
424 /* Register all the types in N->FILTER_LIST. */
425 for (list
= n
->filter_list
; list
; list
= TREE_CHAIN (list
))
426 add_type_for_runtime (TREE_VALUE (list
));
428 /* Chain N to the end of the list. */
430 (*last_p
)->next_catch
= n
;
431 n
->prev_catch
= *last_p
;
434 /* Set the head of the list the first time through the loop. */
438 tag
= streamer_read_record_start (ib
);
445 /* Read and return EH region IX from input block IB, using descriptors
449 input_eh_region (struct lto_input_block
*ib
, struct data_in
*data_in
, int ix
)
454 /* Read the region header. */
455 tag
= streamer_read_record_start (ib
);
459 r
= ggc_cleared_alloc
<eh_region_d
> ();
460 r
->index
= streamer_read_hwi (ib
);
462 gcc_assert (r
->index
== ix
);
464 /* Read all the region pointers as region numbers. We'll fix up
465 the pointers once the whole array has been read. */
466 r
->outer
= (eh_region
) (intptr_t) streamer_read_hwi (ib
);
467 r
->inner
= (eh_region
) (intptr_t) streamer_read_hwi (ib
);
468 r
->next_peer
= (eh_region
) (intptr_t) streamer_read_hwi (ib
);
472 case LTO_ert_cleanup
:
473 r
->type
= ERT_CLEANUP
;
478 struct eh_catch_d
*last_catch
;
480 r
->u
.eh_try
.first_catch
= lto_input_eh_catch_list (ib
, data_in
,
482 r
->u
.eh_try
.last_catch
= last_catch
;
486 case LTO_ert_allowed_exceptions
:
490 r
->type
= ERT_ALLOWED_EXCEPTIONS
;
491 r
->u
.allowed
.type_list
= stream_read_tree (ib
, data_in
);
492 r
->u
.allowed
.label
= stream_read_tree (ib
, data_in
);
493 r
->u
.allowed
.filter
= streamer_read_uhwi (ib
);
495 for (l
= r
->u
.allowed
.type_list
; l
; l
= TREE_CHAIN (l
))
496 add_type_for_runtime (TREE_VALUE (l
));
500 case LTO_ert_must_not_throw
:
502 r
->type
= ERT_MUST_NOT_THROW
;
503 r
->u
.must_not_throw
.failure_decl
= stream_read_tree (ib
, data_in
);
504 bitpack_d bp
= streamer_read_bitpack (ib
);
505 r
->u
.must_not_throw
.failure_loc
506 = stream_input_location_now (&bp
, data_in
);
514 r
->landing_pads
= (eh_landing_pad
) (intptr_t) streamer_read_hwi (ib
);
520 /* Read and return EH landing pad IX from input block IB, using descriptors
523 static eh_landing_pad
524 input_eh_lp (struct lto_input_block
*ib
, struct data_in
*data_in
, int ix
)
529 /* Read the landing pad header. */
530 tag
= streamer_read_record_start (ib
);
534 lto_tag_check_range (tag
, LTO_eh_landing_pad
, LTO_eh_landing_pad
);
536 lp
= ggc_cleared_alloc
<eh_landing_pad_d
> ();
537 lp
->index
= streamer_read_hwi (ib
);
538 gcc_assert (lp
->index
== ix
);
539 lp
->next_lp
= (eh_landing_pad
) (intptr_t) streamer_read_hwi (ib
);
540 lp
->region
= (eh_region
) (intptr_t) streamer_read_hwi (ib
);
541 lp
->post_landing_pad
= stream_read_tree (ib
, data_in
);
547 /* After reading the EH regions, pointers to peer and children regions
548 are region numbers. This converts all these region numbers into
549 real pointers into the rematerialized regions for FN. ROOT_REGION
550 is the region number for the root EH region in FN. */
553 fixup_eh_region_pointers (struct function
*fn
, HOST_WIDE_INT root_region
)
556 vec
<eh_region
, va_gc
> *eh_array
= fn
->eh
->region_array
;
557 vec
<eh_landing_pad
, va_gc
> *lp_array
= fn
->eh
->lp_array
;
561 gcc_assert (eh_array
&& lp_array
);
563 gcc_assert (root_region
>= 0);
564 fn
->eh
->region_tree
= (*eh_array
)[root_region
];
566 #define FIXUP_EH_REGION(r) (r) = (*eh_array)[(HOST_WIDE_INT) (intptr_t) (r)]
567 #define FIXUP_EH_LP(p) (p) = (*lp_array)[(HOST_WIDE_INT) (intptr_t) (p)]
569 /* Convert all the index numbers stored in pointer fields into
570 pointers to the corresponding slots in the EH region array. */
571 FOR_EACH_VEC_ELT (*eh_array
, i
, r
)
573 /* The array may contain NULL regions. */
577 gcc_assert (i
== (unsigned) r
->index
);
578 FIXUP_EH_REGION (r
->outer
);
579 FIXUP_EH_REGION (r
->inner
);
580 FIXUP_EH_REGION (r
->next_peer
);
581 FIXUP_EH_LP (r
->landing_pads
);
584 /* Convert all the index numbers stored in pointer fields into
585 pointers to the corresponding slots in the EH landing pad array. */
586 FOR_EACH_VEC_ELT (*lp_array
, i
, lp
)
588 /* The array may contain NULL landing pads. */
592 gcc_assert (i
== (unsigned) lp
->index
);
593 FIXUP_EH_LP (lp
->next_lp
);
594 FIXUP_EH_REGION (lp
->region
);
597 #undef FIXUP_EH_REGION
602 /* Initialize EH support. */
607 static bool eh_initialized_p
= false;
609 if (eh_initialized_p
)
612 /* Contrary to most other FEs, we only initialize EH support when at
613 least one of the files in the set contains exception regions in
614 it. Since this happens much later than the call to init_eh in
615 lang_dependent_init, we have to set flag_exceptions and call
616 init_eh again to initialize the EH tables. */
620 eh_initialized_p
= true;
624 /* Read the exception table for FN from IB using the data descriptors
628 input_eh_regions (struct lto_input_block
*ib
, struct data_in
*data_in
,
631 HOST_WIDE_INT i
, root_region
, len
;
634 tag
= streamer_read_record_start (ib
);
638 lto_tag_check_range (tag
, LTO_eh_table
, LTO_eh_table
);
640 /* If the file contains EH regions, then it was compiled with
641 -fexceptions. In that case, initialize the backend EH
647 root_region
= streamer_read_hwi (ib
);
648 gcc_assert (root_region
== (int) root_region
);
650 /* Read the EH region array. */
651 len
= streamer_read_hwi (ib
);
652 gcc_assert (len
== (int) len
);
655 vec_safe_grow_cleared (fn
->eh
->region_array
, len
);
656 for (i
= 0; i
< len
; i
++)
658 eh_region r
= input_eh_region (ib
, data_in
, i
);
659 (*fn
->eh
->region_array
)[i
] = r
;
663 /* Read the landing pads. */
664 len
= streamer_read_hwi (ib
);
665 gcc_assert (len
== (int) len
);
668 vec_safe_grow_cleared (fn
->eh
->lp_array
, len
);
669 for (i
= 0; i
< len
; i
++)
671 eh_landing_pad lp
= input_eh_lp (ib
, data_in
, i
);
672 (*fn
->eh
->lp_array
)[i
] = lp
;
676 /* Read the runtime type data. */
677 len
= streamer_read_hwi (ib
);
678 gcc_assert (len
== (int) len
);
681 vec_safe_grow_cleared (fn
->eh
->ttype_data
, len
);
682 for (i
= 0; i
< len
; i
++)
684 tree ttype
= stream_read_tree (ib
, data_in
);
685 (*fn
->eh
->ttype_data
)[i
] = ttype
;
689 /* Read the table of action chains. */
690 len
= streamer_read_hwi (ib
);
691 gcc_assert (len
== (int) len
);
694 if (targetm
.arm_eabi_unwinder
)
696 vec_safe_grow_cleared (fn
->eh
->ehspec_data
.arm_eabi
, len
);
697 for (i
= 0; i
< len
; i
++)
699 tree t
= stream_read_tree (ib
, data_in
);
700 (*fn
->eh
->ehspec_data
.arm_eabi
)[i
] = t
;
705 vec_safe_grow_cleared (fn
->eh
->ehspec_data
.other
, len
);
706 for (i
= 0; i
< len
; i
++)
708 uchar c
= streamer_read_uchar (ib
);
709 (*fn
->eh
->ehspec_data
.other
)[i
] = c
;
714 /* Reconstruct the EH region tree by fixing up the peer/children
716 fixup_eh_region_pointers (fn
, root_region
);
718 tag
= streamer_read_record_start (ib
);
719 lto_tag_check_range (tag
, LTO_null
, LTO_null
);
723 /* Make a new basic block with index INDEX in function FN. */
726 make_new_block (struct function
*fn
, unsigned int index
)
728 basic_block bb
= alloc_block ();
730 SET_BASIC_BLOCK_FOR_FN (fn
, index
, bb
);
731 n_basic_blocks_for_fn (fn
)++;
736 /* Read a wide-int. */
739 streamer_read_wi (struct lto_input_block
*ib
)
741 HOST_WIDE_INT a
[WIDE_INT_MAX_ELTS
];
743 int prec ATTRIBUTE_UNUSED
= streamer_read_uhwi (ib
);
744 int len
= streamer_read_uhwi (ib
);
745 for (i
= 0; i
< len
; i
++)
746 a
[i
] = streamer_read_hwi (ib
);
747 return widest_int::from_array (a
, len
);
751 /* Read the CFG for function FN from input block IB. */
754 input_cfg (struct lto_input_block
*ib
, struct data_in
*data_in
,
756 int count_materialization_scale
)
758 unsigned int bb_count
;
763 init_empty_tree_cfg_for_function (fn
);
764 init_ssa_operands (fn
);
766 profile_status_for_fn (fn
) = streamer_read_enum (ib
, profile_status_d
,
769 bb_count
= streamer_read_uhwi (ib
);
771 last_basic_block_for_fn (fn
) = bb_count
;
772 if (bb_count
> basic_block_info_for_fn (fn
)->length ())
773 vec_safe_grow_cleared (basic_block_info_for_fn (fn
), bb_count
);
775 if (bb_count
> label_to_block_map_for_fn (fn
)->length ())
776 vec_safe_grow_cleared (label_to_block_map_for_fn (fn
), bb_count
);
778 index
= streamer_read_hwi (ib
);
781 basic_block bb
= BASIC_BLOCK_FOR_FN (fn
, index
);
782 unsigned int edge_count
;
785 bb
= make_new_block (fn
, index
);
787 edge_count
= streamer_read_uhwi (ib
);
789 /* Connect up the CFG. */
790 for (i
= 0; i
< edge_count
; i
++)
792 unsigned int dest_index
;
793 unsigned int edge_flags
;
799 dest_index
= streamer_read_uhwi (ib
);
800 probability
= (int) streamer_read_hwi (ib
);
801 count
= apply_scale ((gcov_type
) streamer_read_gcov_count (ib
),
802 count_materialization_scale
);
803 edge_flags
= streamer_read_uhwi (ib
);
805 dest
= BASIC_BLOCK_FOR_FN (fn
, dest_index
);
808 dest
= make_new_block (fn
, dest_index
);
810 e
= make_edge (bb
, dest
, edge_flags
);
811 e
->probability
= probability
;
815 index
= streamer_read_hwi (ib
);
818 p_bb
= ENTRY_BLOCK_PTR_FOR_FN (fn
);
819 index
= streamer_read_hwi (ib
);
822 basic_block bb
= BASIC_BLOCK_FOR_FN (fn
, index
);
826 index
= streamer_read_hwi (ib
);
829 /* ??? The cfgloop interface is tied to cfun. */
830 gcc_assert (cfun
== fn
);
832 /* Input the loop tree. */
833 unsigned n_loops
= streamer_read_uhwi (ib
);
837 struct loops
*loops
= ggc_cleared_alloc
<struct loops
> ();
838 init_loops_structure (fn
, loops
, n_loops
);
839 set_loops_for_fn (fn
, loops
);
841 /* Input each loop and associate it with its loop header so
842 flow_loops_find can rebuild the loop tree. */
843 for (unsigned i
= 1; i
< n_loops
; ++i
)
845 int header_index
= streamer_read_hwi (ib
);
846 if (header_index
== -1)
848 loops
->larray
->quick_push (NULL
);
852 struct loop
*loop
= alloc_loop ();
853 loop
->header
= BASIC_BLOCK_FOR_FN (fn
, header_index
);
854 loop
->header
->loop_father
= loop
;
856 /* Read everything copy_loop_info copies. */
857 loop
->estimate_state
= streamer_read_enum (ib
, loop_estimation
, EST_LAST
);
858 loop
->any_upper_bound
= streamer_read_hwi (ib
);
859 if (loop
->any_upper_bound
)
860 loop
->nb_iterations_upper_bound
= streamer_read_wi (ib
);
861 loop
->any_estimate
= streamer_read_hwi (ib
);
862 if (loop
->any_estimate
)
863 loop
->nb_iterations_estimate
= streamer_read_wi (ib
);
865 /* Read OMP SIMD related info. */
866 loop
->safelen
= streamer_read_hwi (ib
);
867 loop
->dont_vectorize
= streamer_read_hwi (ib
);
868 loop
->force_vectorize
= streamer_read_hwi (ib
);
869 loop
->simduid
= stream_read_tree (ib
, data_in
);
871 place_new_loop (fn
, loop
);
873 /* flow_loops_find doesn't like loops not in the tree, hook them
874 all as siblings of the tree root temporarily. */
875 flow_loop_tree_node_add (loops
->tree_root
, loop
);
878 /* Rebuild the loop tree. */
879 flow_loops_find (loops
);
883 /* Read the SSA names array for function FN from DATA_IN using input
887 input_ssa_names (struct lto_input_block
*ib
, struct data_in
*data_in
,
890 unsigned int i
, size
;
892 size
= streamer_read_uhwi (ib
);
893 init_ssanames (fn
, size
);
895 i
= streamer_read_uhwi (ib
);
901 /* Skip over the elements that had been freed. */
902 while (SSANAMES (fn
)->length () < i
)
903 SSANAMES (fn
)->quick_push (NULL_TREE
);
905 is_default_def
= (streamer_read_uchar (ib
) != 0);
906 name
= stream_read_tree (ib
, data_in
);
907 ssa_name
= make_ssa_name_fn (fn
, name
, gimple_build_nop ());
910 set_ssa_default_def (cfun
, SSA_NAME_VAR (ssa_name
), ssa_name
);
912 i
= streamer_read_uhwi (ib
);
917 /* Go through all NODE edges and fixup call_stmt pointers
918 so they point to STMTS. */
921 fixup_call_stmt_edges_1 (struct cgraph_node
*node
, gimple
*stmts
,
924 struct cgraph_edge
*cedge
;
925 struct ipa_ref
*ref
= NULL
;
928 for (cedge
= node
->callees
; cedge
; cedge
= cedge
->next_callee
)
930 if (gimple_stmt_max_uid (fn
) < cedge
->lto_stmt_uid
)
931 fatal_error (input_location
,
932 "Cgraph edge statement index out of range");
933 cedge
->call_stmt
= as_a
<gcall
*> (stmts
[cedge
->lto_stmt_uid
- 1]);
934 if (!cedge
->call_stmt
)
935 fatal_error (input_location
,
936 "Cgraph edge statement index not found");
938 for (cedge
= node
->indirect_calls
; cedge
; cedge
= cedge
->next_callee
)
940 if (gimple_stmt_max_uid (fn
) < cedge
->lto_stmt_uid
)
941 fatal_error (input_location
,
942 "Cgraph edge statement index out of range");
943 cedge
->call_stmt
= as_a
<gcall
*> (stmts
[cedge
->lto_stmt_uid
- 1]);
944 if (!cedge
->call_stmt
)
945 fatal_error (input_location
, "Cgraph edge statement index not found");
947 for (i
= 0; node
->iterate_reference (i
, ref
); i
++)
948 if (ref
->lto_stmt_uid
)
950 if (gimple_stmt_max_uid (fn
) < ref
->lto_stmt_uid
)
951 fatal_error (input_location
,
952 "Reference statement index out of range");
953 ref
->stmt
= stmts
[ref
->lto_stmt_uid
- 1];
955 fatal_error (input_location
, "Reference statement index not found");
960 /* Fixup call_stmt pointers in NODE and all clones. */
963 fixup_call_stmt_edges (struct cgraph_node
*orig
, gimple
*stmts
)
965 struct cgraph_node
*node
;
968 while (orig
->clone_of
)
969 orig
= orig
->clone_of
;
970 fn
= DECL_STRUCT_FUNCTION (orig
->decl
);
972 fixup_call_stmt_edges_1 (orig
, stmts
, fn
);
974 for (node
= orig
->clones
; node
!= orig
;)
976 fixup_call_stmt_edges_1 (node
, stmts
, fn
);
979 else if (node
->next_sibling_clone
)
980 node
= node
->next_sibling_clone
;
983 while (node
!= orig
&& !node
->next_sibling_clone
)
984 node
= node
->clone_of
;
986 node
= node
->next_sibling_clone
;
992 /* Input the base body of struct function FN from DATA_IN
993 using input block IB. */
996 input_struct_function_base (struct function
*fn
, struct data_in
*data_in
,
997 struct lto_input_block
*ib
)
1002 /* Read the static chain and non-local goto save area. */
1003 fn
->static_chain_decl
= stream_read_tree (ib
, data_in
);
1004 fn
->nonlocal_goto_save_area
= stream_read_tree (ib
, data_in
);
1006 /* Read all the local symbols. */
1007 len
= streamer_read_hwi (ib
);
1011 vec_safe_grow_cleared (fn
->local_decls
, len
);
1012 for (i
= 0; i
< len
; i
++)
1014 tree t
= stream_read_tree (ib
, data_in
);
1015 (*fn
->local_decls
)[i
] = t
;
1019 /* Input the current IL state of the function. */
1020 fn
->curr_properties
= streamer_read_uhwi (ib
);
1022 /* Read all the attributes for FN. */
1023 bp
= streamer_read_bitpack (ib
);
1024 fn
->is_thunk
= bp_unpack_value (&bp
, 1);
1025 fn
->has_local_explicit_reg_vars
= bp_unpack_value (&bp
, 1);
1026 fn
->returns_pcc_struct
= bp_unpack_value (&bp
, 1);
1027 fn
->returns_struct
= bp_unpack_value (&bp
, 1);
1028 fn
->can_throw_non_call_exceptions
= bp_unpack_value (&bp
, 1);
1029 fn
->can_delete_dead_exceptions
= bp_unpack_value (&bp
, 1);
1030 fn
->always_inline_functions_inlined
= bp_unpack_value (&bp
, 1);
1031 fn
->after_inlining
= bp_unpack_value (&bp
, 1);
1032 fn
->stdarg
= bp_unpack_value (&bp
, 1);
1033 fn
->has_nonlocal_label
= bp_unpack_value (&bp
, 1);
1034 fn
->calls_alloca
= bp_unpack_value (&bp
, 1);
1035 fn
->calls_setjmp
= bp_unpack_value (&bp
, 1);
1036 fn
->has_force_vectorize_loops
= bp_unpack_value (&bp
, 1);
1037 fn
->has_simduid_loops
= bp_unpack_value (&bp
, 1);
1038 fn
->va_list_fpr_size
= bp_unpack_value (&bp
, 8);
1039 fn
->va_list_gpr_size
= bp_unpack_value (&bp
, 8);
1040 fn
->last_clique
= bp_unpack_value (&bp
, sizeof (short) * 8);
1042 /* Input the function start and end loci. */
1043 fn
->function_start_locus
= stream_input_location_now (&bp
, data_in
);
1044 fn
->function_end_locus
= stream_input_location_now (&bp
, data_in
);
1048 /* Read the body of function FN_DECL from DATA_IN using input block IB. */
1051 input_function (tree fn_decl
, struct data_in
*data_in
,
1052 struct lto_input_block
*ib
, struct lto_input_block
*ib_cfg
)
1054 struct function
*fn
;
1058 struct cgraph_node
*node
;
1060 tag
= streamer_read_record_start (ib
);
1061 lto_tag_check (tag
, LTO_function
);
1063 /* Read decls for parameters and args. */
1064 DECL_RESULT (fn_decl
) = stream_read_tree (ib
, data_in
);
1065 DECL_ARGUMENTS (fn_decl
) = streamer_read_chain (ib
, data_in
);
1067 /* Read the tree of lexical scopes for the function. */
1068 DECL_INITIAL (fn_decl
) = stream_read_tree (ib
, data_in
);
1070 if (!streamer_read_uhwi (ib
))
1073 push_struct_function (fn_decl
);
1074 fn
= DECL_STRUCT_FUNCTION (fn_decl
);
1076 /* We input IL in SSA form. */
1077 cfun
->gimple_df
->in_ssa_p
= true;
1079 gimple_register_cfg_hooks ();
1081 node
= cgraph_node::get (fn_decl
);
1083 node
= cgraph_node::create (fn_decl
);
1084 input_struct_function_base (fn
, data_in
, ib
);
1085 input_cfg (ib_cfg
, data_in
, fn
, node
->count_materialization_scale
);
1087 /* Read all the SSA names. */
1088 input_ssa_names (ib
, data_in
, fn
);
1090 /* Read the exception handling regions in the function. */
1091 input_eh_regions (ib
, data_in
, fn
);
1093 gcc_assert (DECL_INITIAL (fn_decl
));
1094 DECL_SAVED_TREE (fn_decl
) = NULL_TREE
;
1096 /* Read all the basic blocks. */
1097 tag
= streamer_read_record_start (ib
);
1100 input_bb (ib
, tag
, data_in
, fn
,
1101 node
->count_materialization_scale
);
1102 tag
= streamer_read_record_start (ib
);
1105 /* Fix up the call statements that are mentioned in the callgraph
1107 set_gimple_stmt_max_uid (cfun
, 0);
1108 FOR_ALL_BB_FN (bb
, cfun
)
1110 gimple_stmt_iterator gsi
;
1111 for (gsi
= gsi_start_phis (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1113 gimple stmt
= gsi_stmt (gsi
);
1114 gimple_set_uid (stmt
, inc_gimple_stmt_max_uid (cfun
));
1116 for (gsi
= gsi_start_bb (bb
); !gsi_end_p (gsi
); gsi_next (&gsi
))
1118 gimple stmt
= gsi_stmt (gsi
);
1119 gimple_set_uid (stmt
, inc_gimple_stmt_max_uid (cfun
));
1122 stmts
= (gimple
*) xcalloc (gimple_stmt_max_uid (fn
), sizeof (gimple
));
1123 FOR_ALL_BB_FN (bb
, cfun
)
1125 gimple_stmt_iterator bsi
= gsi_start_phis (bb
);
1126 while (!gsi_end_p (bsi
))
1128 gimple stmt
= gsi_stmt (bsi
);
1130 stmts
[gimple_uid (stmt
)] = stmt
;
1132 bsi
= gsi_start_bb (bb
);
1133 while (!gsi_end_p (bsi
))
1135 gimple stmt
= gsi_stmt (bsi
);
1136 /* If we're recompiling LTO objects with debug stmts but
1137 we're not supposed to have debug stmts, remove them now.
1138 We can't remove them earlier because this would cause uid
1139 mismatches in fixups, but we can do it at this point, as
1140 long as debug stmts don't require fixups. */
1141 if (!MAY_HAVE_DEBUG_STMTS
&& !flag_wpa
&& is_gimple_debug (stmt
))
1143 gimple_stmt_iterator gsi
= bsi
;
1145 gsi_remove (&gsi
, true);
1150 stmts
[gimple_uid (stmt
)] = stmt
;
1155 /* Set the gimple body to the statement sequence in the entry
1156 basic block. FIXME lto, this is fairly hacky. The existence
1157 of a gimple body is used by the cgraph routines, but we should
1158 really use the presence of the CFG. */
1160 edge_iterator ei
= ei_start (ENTRY_BLOCK_PTR_FOR_FN (cfun
)->succs
);
1161 gimple_set_body (fn_decl
, bb_seq (ei_edge (ei
)->dest
));
1164 fixup_call_stmt_edges (node
, stmts
);
1165 execute_all_ipa_stmt_fixups (node
, stmts
);
1167 update_ssa (TODO_update_ssa_only_virtuals
);
1168 free_dominance_info (CDI_DOMINATORS
);
1169 free_dominance_info (CDI_POST_DOMINATORS
);
1174 /* Read the body of function FN_DECL from DATA_IN using input block IB. */
1177 input_constructor (tree var
, struct data_in
*data_in
,
1178 struct lto_input_block
*ib
)
1180 DECL_INITIAL (var
) = stream_read_tree (ib
, data_in
);
1184 /* Read the body from DATA for function NODE and fill it in.
1185 FILE_DATA are the global decls and types. SECTION_TYPE is either
1186 LTO_section_function_body or LTO_section_static_initializer. If
1187 section type is LTO_section_function_body, FN must be the decl for
1191 lto_read_body_or_constructor (struct lto_file_decl_data
*file_data
, struct symtab_node
*node
,
1192 const char *data
, enum lto_section_type section_type
)
1194 const struct lto_function_header
*header
;
1195 struct data_in
*data_in
;
1199 tree fn_decl
= node
->decl
;
1201 header
= (const struct lto_function_header
*) data
;
1202 if (TREE_CODE (node
->decl
) == FUNCTION_DECL
)
1204 cfg_offset
= sizeof (struct lto_function_header
);
1205 main_offset
= cfg_offset
+ header
->cfg_size
;
1206 string_offset
= main_offset
+ header
->main_size
;
1210 main_offset
= sizeof (struct lto_function_header
);
1211 string_offset
= main_offset
+ header
->main_size
;
1214 data_in
= lto_data_in_create (file_data
, data
+ string_offset
,
1215 header
->string_size
, vNULL
);
1217 if (section_type
== LTO_section_function_body
)
1219 struct lto_in_decl_state
*decl_state
;
1222 gcc_checking_assert (node
);
1224 /* Use the function's decl state. */
1225 decl_state
= lto_get_function_in_decl_state (file_data
, fn_decl
);
1226 gcc_assert (decl_state
);
1227 file_data
->current_decl_state
= decl_state
;
1230 /* Set up the struct function. */
1231 from
= data_in
->reader_cache
->nodes
.length ();
1232 lto_input_block
ib_main (data
+ main_offset
, header
->main_size
,
1233 file_data
->mode_table
);
1234 if (TREE_CODE (node
->decl
) == FUNCTION_DECL
)
1236 lto_input_block
ib_cfg (data
+ cfg_offset
, header
->cfg_size
,
1237 file_data
->mode_table
);
1238 input_function (fn_decl
, data_in
, &ib_main
, &ib_cfg
);
1241 input_constructor (fn_decl
, data_in
, &ib_main
);
1242 data_in
->location_cache
.apply_location_cache ();
1243 /* And fixup types we streamed locally. */
1245 struct streamer_tree_cache_d
*cache
= data_in
->reader_cache
;
1246 unsigned len
= cache
->nodes
.length ();
1248 for (i
= len
; i
-- > from
;)
1250 tree t
= streamer_tree_cache_get_tree (cache
, i
);
1256 gcc_assert (TYPE_CANONICAL (t
) == NULL_TREE
);
1257 TYPE_CANONICAL (t
) = TYPE_MAIN_VARIANT (t
);
1258 if (TYPE_MAIN_VARIANT (t
) != t
)
1260 gcc_assert (TYPE_NEXT_VARIANT (t
) == NULL_TREE
);
1261 TYPE_NEXT_VARIANT (t
)
1262 = TYPE_NEXT_VARIANT (TYPE_MAIN_VARIANT (t
));
1263 TYPE_NEXT_VARIANT (TYPE_MAIN_VARIANT (t
)) = t
;
1269 /* Restore decl state */
1270 file_data
->current_decl_state
= file_data
->global_decl_state
;
1273 lto_data_in_delete (data_in
);
1277 /* Read the body of NODE using DATA. FILE_DATA holds the global
1281 lto_input_function_body (struct lto_file_decl_data
*file_data
,
1282 struct cgraph_node
*node
, const char *data
)
1284 lto_read_body_or_constructor (file_data
, node
, data
, LTO_section_function_body
);
1287 /* Read the body of NODE using DATA. FILE_DATA holds the global
1291 lto_input_variable_constructor (struct lto_file_decl_data
*file_data
,
1292 struct varpool_node
*node
, const char *data
)
1294 lto_read_body_or_constructor (file_data
, node
, data
, LTO_section_function_body
);
1298 /* Read the physical representation of a tree node EXPR from
1299 input block IB using the per-file context in DATA_IN. */
1302 lto_read_tree_1 (struct lto_input_block
*ib
, struct data_in
*data_in
, tree expr
)
1304 /* Read all the bitfield values in EXPR. Note that for LTO, we
1305 only write language-independent bitfields, so no more unpacking is
1307 streamer_read_tree_bitfields (ib
, data_in
, expr
);
1309 /* Read all the pointer fields in EXPR. */
1310 streamer_read_tree_body (ib
, data_in
, expr
);
1312 /* Read any LTO-specific data not read by the tree streamer. */
1314 && TREE_CODE (expr
) != FUNCTION_DECL
1315 && TREE_CODE (expr
) != TRANSLATION_UNIT_DECL
)
1316 DECL_INITIAL (expr
) = stream_read_tree (ib
, data_in
);
1318 /* We should never try to instantiate an MD or NORMAL builtin here. */
1319 if (TREE_CODE (expr
) == FUNCTION_DECL
)
1320 gcc_assert (!streamer_handle_as_builtin_p (expr
));
1322 #ifdef LTO_STREAMER_DEBUG
1323 /* Remove the mapping to RESULT's original address set by
1324 streamer_alloc_tree. */
1325 lto_orig_address_remove (expr
);
1329 /* Read the physical representation of a tree node with tag TAG from
1330 input block IB using the per-file context in DATA_IN. */
1333 lto_read_tree (struct lto_input_block
*ib
, struct data_in
*data_in
,
1334 enum LTO_tags tag
, hashval_t hash
)
1336 /* Instantiate a new tree node. */
1337 tree result
= streamer_alloc_tree (ib
, data_in
, tag
);
1339 /* Enter RESULT in the reader cache. This will make RESULT
1340 available so that circular references in the rest of the tree
1341 structure can be resolved in subsequent calls to stream_read_tree. */
1342 streamer_tree_cache_append (data_in
->reader_cache
, result
, hash
);
1344 lto_read_tree_1 (ib
, data_in
, result
);
1346 /* end_marker = */ streamer_read_uchar (ib
);
1352 /* Populate the reader cache with trees materialized from the SCC
1353 following in the IB, DATA_IN stream. */
1356 lto_input_scc (struct lto_input_block
*ib
, struct data_in
*data_in
,
1357 unsigned *len
, unsigned *entry_len
)
1359 /* A blob of unnamed tree nodes, fill the cache from it and
1361 unsigned size
= streamer_read_uhwi (ib
);
1362 hashval_t scc_hash
= streamer_read_uhwi (ib
);
1363 unsigned scc_entry_len
= 1;
1367 enum LTO_tags tag
= streamer_read_record_start (ib
);
1368 lto_input_tree_1 (ib
, data_in
, tag
, scc_hash
);
1372 unsigned int first
= data_in
->reader_cache
->nodes
.length ();
1375 scc_entry_len
= streamer_read_uhwi (ib
);
1377 /* Materialize size trees by reading their headers. */
1378 for (unsigned i
= 0; i
< size
; ++i
)
1380 enum LTO_tags tag
= streamer_read_record_start (ib
);
1382 || (tag
>= LTO_field_decl_ref
&& tag
<= LTO_global_decl_ref
)
1383 || tag
== LTO_tree_pickle_reference
1384 || tag
== LTO_builtin_decl
1385 || tag
== LTO_integer_cst
1386 || tag
== LTO_tree_scc
)
1389 result
= streamer_alloc_tree (ib
, data_in
, tag
);
1390 streamer_tree_cache_append (data_in
->reader_cache
, result
, 0);
1393 /* Read the tree bitpacks and references. */
1394 for (unsigned i
= 0; i
< size
; ++i
)
1396 result
= streamer_tree_cache_get_tree (data_in
->reader_cache
,
1398 lto_read_tree_1 (ib
, data_in
, result
);
1399 /* end_marker = */ streamer_read_uchar (ib
);
1404 *entry_len
= scc_entry_len
;
1409 /* Read a tree from input block IB using the per-file context in
1410 DATA_IN. This context is used, for example, to resolve references
1411 to previously read nodes. */
1414 lto_input_tree_1 (struct lto_input_block
*ib
, struct data_in
*data_in
,
1415 enum LTO_tags tag
, hashval_t hash
)
1419 gcc_assert ((unsigned) tag
< (unsigned) LTO_NUM_TAGS
);
1421 if (tag
== LTO_null
)
1423 else if (tag
>= LTO_field_decl_ref
&& tag
<= LTO_namelist_decl_ref
)
1425 /* If TAG is a reference to an indexable tree, the next value
1426 in IB is the index into the table where we expect to find
1428 result
= lto_input_tree_ref (ib
, data_in
, cfun
, tag
);
1430 else if (tag
== LTO_tree_pickle_reference
)
1432 /* If TAG is a reference to a previously read tree, look it up in
1433 the reader cache. */
1434 result
= streamer_get_pickled_tree (ib
, data_in
);
1436 else if (tag
== LTO_builtin_decl
)
1438 /* If we are going to read a built-in function, all we need is
1439 the code and class. */
1440 result
= streamer_get_builtin_tree (ib
, data_in
);
1442 else if (tag
== LTO_integer_cst
)
1444 /* For shared integer constants in singletons we can use the
1445 existing tree integer constant merging code. */
1446 tree type
= stream_read_tree (ib
, data_in
);
1447 unsigned HOST_WIDE_INT len
= streamer_read_uhwi (ib
);
1448 unsigned HOST_WIDE_INT i
;
1449 HOST_WIDE_INT a
[WIDE_INT_MAX_ELTS
];
1451 for (i
= 0; i
< len
; i
++)
1452 a
[i
] = streamer_read_hwi (ib
);
1453 gcc_assert (TYPE_PRECISION (type
) <= MAX_BITSIZE_MODE_ANY_INT
);
1454 result
= wide_int_to_tree (type
, wide_int::from_array
1455 (a
, len
, TYPE_PRECISION (type
)));
1456 streamer_tree_cache_append (data_in
->reader_cache
, result
, hash
);
1458 else if (tag
== LTO_tree_scc
)
1462 /* Otherwise, materialize a new node from IB. */
1463 result
= lto_read_tree (ib
, data_in
, tag
, hash
);
1470 lto_input_tree (struct lto_input_block
*ib
, struct data_in
*data_in
)
1474 /* Input and skip SCCs. */
1475 while ((tag
= streamer_read_record_start (ib
)) == LTO_tree_scc
)
1477 unsigned len
, entry_len
;
1478 lto_input_scc (ib
, data_in
, &len
, &entry_len
);
1480 return lto_input_tree_1 (ib
, data_in
, tag
, 0);
1484 /* Input toplevel asms. */
1487 lto_input_toplevel_asms (struct lto_file_decl_data
*file_data
, int order_base
)
1490 const char *data
= lto_get_section_data (file_data
, LTO_section_asm
,
1492 const struct lto_simple_header_with_strings
*header
1493 = (const struct lto_simple_header_with_strings
*) data
;
1495 struct data_in
*data_in
;
1501 string_offset
= sizeof (*header
) + header
->main_size
;
1503 lto_input_block
ib (data
+ sizeof (*header
), header
->main_size
,
1504 file_data
->mode_table
);
1506 data_in
= lto_data_in_create (file_data
, data
+ string_offset
,
1507 header
->string_size
, vNULL
);
1509 while ((str
= streamer_read_string_cst (data_in
, &ib
)))
1511 asm_node
*node
= symtab
->finalize_toplevel_asm (str
);
1512 node
->order
= streamer_read_hwi (&ib
) + order_base
;
1513 if (node
->order
>= symtab
->order
)
1514 symtab
->order
= node
->order
+ 1;
1517 lto_data_in_delete (data_in
);
1519 lto_free_section_data (file_data
, LTO_section_asm
, NULL
, data
, len
);
1523 /* Input mode table. */
1526 lto_input_mode_table (struct lto_file_decl_data
*file_data
)
1529 const char *data
= lto_get_section_data (file_data
, LTO_section_mode_table
,
1533 internal_error ("cannot read LTO mode table from %s",
1534 file_data
->file_name
);
1538 unsigned char *table
= ggc_cleared_vec_alloc
<unsigned char> (1 << 8);
1539 file_data
->mode_table
= table
;
1540 const struct lto_simple_header_with_strings
*header
1541 = (const struct lto_simple_header_with_strings
*) data
;
1543 struct data_in
*data_in
;
1544 string_offset
= sizeof (*header
) + header
->main_size
;
1546 lto_input_block
ib (data
+ sizeof (*header
), header
->main_size
, NULL
);
1547 data_in
= lto_data_in_create (file_data
, data
+ string_offset
,
1548 header
->string_size
, vNULL
);
1549 bitpack_d bp
= streamer_read_bitpack (&ib
);
1551 table
[VOIDmode
] = VOIDmode
;
1552 table
[BLKmode
] = BLKmode
;
1554 while ((m
= bp_unpack_value (&bp
, 8)) != VOIDmode
)
1556 enum mode_class mclass
1557 = bp_unpack_enum (&bp
, mode_class
, MAX_MODE_CLASS
);
1558 unsigned int size
= bp_unpack_value (&bp
, 8);
1559 unsigned int prec
= bp_unpack_value (&bp
, 16);
1560 machine_mode inner
= (machine_mode
) table
[bp_unpack_value (&bp
, 8)];
1561 unsigned int nunits
= bp_unpack_value (&bp
, 8);
1562 unsigned int ibit
= 0, fbit
= 0;
1563 unsigned int real_fmt_len
= 0;
1564 const char *real_fmt_name
= NULL
;
1571 ibit
= bp_unpack_value (&bp
, 8);
1572 fbit
= bp_unpack_value (&bp
, 8);
1575 case MODE_DECIMAL_FLOAT
:
1576 real_fmt_name
= bp_unpack_indexed_string (data_in
, &bp
,
1582 /* First search just the GET_CLASS_NARROWEST_MODE to wider modes,
1583 if not found, fallback to all modes. */
1585 for (pass
= 0; pass
< 2; pass
++)
1586 for (machine_mode mr
= pass
? VOIDmode
1587 : GET_CLASS_NARROWEST_MODE (mclass
);
1588 pass
? mr
< MAX_MACHINE_MODE
: mr
!= VOIDmode
;
1589 pass
? mr
= (machine_mode
) (m
+ 1)
1590 : mr
= GET_MODE_WIDER_MODE (mr
))
1591 if (GET_MODE_CLASS (mr
) != mclass
1592 || GET_MODE_SIZE (mr
) != size
1593 || GET_MODE_PRECISION (mr
) != prec
1594 || GET_MODE_INNER (mr
) != inner
1595 || GET_MODE_IBIT (mr
) != ibit
1596 || GET_MODE_FBIT (mr
) != fbit
1597 || GET_MODE_NUNITS (mr
) != nunits
)
1599 else if ((mclass
== MODE_FLOAT
|| mclass
== MODE_DECIMAL_FLOAT
)
1600 && strcmp (REAL_MODE_FORMAT (mr
)->name
, real_fmt_name
) != 0)
1608 unsigned int mname_len
;
1609 const char *mname
= bp_unpack_indexed_string (data_in
, &bp
, &mname_len
);
1614 case MODE_VECTOR_INT
:
1615 case MODE_VECTOR_FLOAT
:
1616 case MODE_VECTOR_FRACT
:
1617 case MODE_VECTOR_UFRACT
:
1618 case MODE_VECTOR_ACCUM
:
1619 case MODE_VECTOR_UACCUM
:
1620 /* For unsupported vector modes just use BLKmode,
1621 if the scalar mode is supported. */
1622 if (inner
!= VOIDmode
)
1629 fatal_error (UNKNOWN_LOCATION
, "unsupported mode %s\n", mname
);
1634 lto_data_in_delete (data_in
);
1636 lto_free_section_data (file_data
, LTO_section_mode_table
, NULL
, data
, len
);
1640 /* Initialization for the LTO reader. */
1643 lto_reader_init (void)
1645 lto_streamer_init ();
1646 file_name_hash_table
1647 = new hash_table
<freeing_string_slot_hasher
> (37);
1651 /* Create a new data_in object for FILE_DATA. STRINGS is the string
1652 table to use with LEN strings. RESOLUTIONS is the vector of linker
1653 resolutions (NULL if not using a linker plugin). */
1656 lto_data_in_create (struct lto_file_decl_data
*file_data
, const char *strings
,
1658 vec
<ld_plugin_symbol_resolution_t
> resolutions
)
1660 struct data_in
*data_in
= new (struct data_in
);
1661 data_in
->file_data
= file_data
;
1662 data_in
->strings
= strings
;
1663 data_in
->strings_len
= len
;
1664 data_in
->globals_resolution
= resolutions
;
1665 data_in
->reader_cache
= streamer_tree_cache_create (false, false, true);
1670 /* Remove DATA_IN. */
1673 lto_data_in_delete (struct data_in
*data_in
)
1675 data_in
->globals_resolution
.release ();
1676 streamer_tree_cache_delete (data_in
->reader_cache
);