comparison gcc/lto-streamer-in.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Read the GIMPLE representation from a file stream. 1 /* Read the GIMPLE representation from a file stream.
2 2
3 Copyright (C) 2009-2018 Free Software Foundation, Inc. 3 Copyright (C) 2009-2020 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
40 #include "tree-ssa.h" 40 #include "tree-ssa.h"
41 #include "except.h" 41 #include "except.h"
42 #include "cgraph.h" 42 #include "cgraph.h"
43 #include "cfgloop.h" 43 #include "cfgloop.h"
44 #include "debug.h" 44 #include "debug.h"
45 45 #include "alloc-pool.h"
46 46
47 struct freeing_string_slot_hasher : string_slot_hasher 47 /* Allocator used to hold string slot entries for line map streaming. */
48 { 48 static struct object_allocator<struct string_slot> *string_slot_allocator;
49 static inline void remove (value_type *);
50 };
51
52 inline void
53 freeing_string_slot_hasher::remove (value_type *v)
54 {
55 free (v);
56 }
57 49
58 /* The table to hold the file names. */ 50 /* The table to hold the file names. */
59 static hash_table<freeing_string_slot_hasher> *file_name_hash_table; 51 static hash_table<string_slot_hasher> *file_name_hash_table;
52
53 /* This obstack holds file names used in locators. Line map datastructures
54 points here and thus it needs to be kept allocated as long as linemaps
55 exists. */
56 static struct obstack file_name_obstack;
60 57
61 58
62 /* Check that tag ACTUAL has one of the given values. NUM_TAGS is the 59 /* Check that tag ACTUAL has one of the given values. NUM_TAGS is the
63 number of valid tag values to check. */ 60 number of valid tag values to check. */
64 61
82 79
83 80
84 /* Read LENGTH bytes from STREAM to ADDR. */ 81 /* Read LENGTH bytes from STREAM to ADDR. */
85 82
86 void 83 void
87 lto_input_data_block (struct lto_input_block *ib, void *addr, size_t length) 84 lto_input_data_block (class lto_input_block *ib, void *addr, size_t length)
88 { 85 {
89 size_t i; 86 size_t i;
90 unsigned char *const buffer = (unsigned char *) addr; 87 unsigned char *const buffer = (unsigned char *) addr;
91 88
92 for (i = 0; i < length; i++) 89 for (i = 0; i < length; i++)
111 if (*slot == NULL) 108 if (*slot == NULL)
112 { 109 {
113 char *saved_string; 110 char *saved_string;
114 struct string_slot *new_slot; 111 struct string_slot *new_slot;
115 112
116 saved_string = (char *) xmalloc (len + 1); 113 saved_string = XOBNEWVEC (&file_name_obstack, char, len + 1);
117 new_slot = XCNEW (struct string_slot); 114 new_slot = string_slot_allocator->allocate ();
118 memcpy (saved_string, string, len + 1); 115 memcpy (saved_string, string, len + 1);
119 new_slot->s = saved_string; 116 new_slot->s = saved_string;
120 new_slot->len = len; 117 new_slot->len = len;
121 *slot = new_slot; 118 *slot = new_slot;
122 return saved_string; 119 return saved_string;
230 or add it to the location cache. 227 or add it to the location cache.
231 It is neccesary to call apply_location_cache to get *LOC updated. */ 228 It is neccesary to call apply_location_cache to get *LOC updated. */
232 229
233 void 230 void
234 lto_location_cache::input_location (location_t *loc, struct bitpack_d *bp, 231 lto_location_cache::input_location (location_t *loc, struct bitpack_d *bp,
235 struct data_in *data_in) 232 class data_in *data_in)
236 { 233 {
237 static const char *stream_file; 234 static const char *stream_file;
238 static int stream_line; 235 static int stream_line;
239 static int stream_col; 236 static int stream_col;
240 static bool stream_sysp; 237 static bool stream_sysp;
285 or add it to the location cache. 282 or add it to the location cache.
286 It is neccesary to call apply_location_cache to get *LOC updated. */ 283 It is neccesary to call apply_location_cache to get *LOC updated. */
287 284
288 void 285 void
289 lto_input_location (location_t *loc, struct bitpack_d *bp, 286 lto_input_location (location_t *loc, struct bitpack_d *bp,
290 struct data_in *data_in) 287 class data_in *data_in)
291 { 288 {
292 data_in->location_cache.input_location (loc, bp, data_in); 289 data_in->location_cache.input_location (loc, bp, data_in);
293 } 290 }
294 291
295 /* Read location and return it instead of going through location caching. 292 /* Read location and return it instead of going through location caching.
296 This should be used only when the resulting location is not going to be 293 This should be used only when the resulting location is not going to be
297 discarded. */ 294 discarded. */
298 295
299 location_t 296 location_t
300 stream_input_location_now (struct bitpack_d *bp, struct data_in *data_in) 297 stream_input_location_now (struct bitpack_d *bp, class data_in *data_in)
301 { 298 {
302 location_t loc; 299 location_t loc;
303 stream_input_location (&loc, bp, data_in); 300 stream_input_location (&loc, bp, data_in);
304 data_in->location_cache.apply_location_cache (); 301 data_in->location_cache.apply_location_cache ();
305 return loc; 302 return loc;
311 be looked up in one of the symbol tables, otherwise read the pysical 308 be looked up in one of the symbol tables, otherwise read the pysical
312 representation of the tree using stream_read_tree. FN is the 309 representation of the tree using stream_read_tree. FN is the
313 function scope for the read tree. */ 310 function scope for the read tree. */
314 311
315 tree 312 tree
316 lto_input_tree_ref (struct lto_input_block *ib, struct data_in *data_in, 313 lto_input_tree_ref (class lto_input_block *ib, class data_in *data_in,
317 struct function *fn, enum LTO_tags tag) 314 struct function *fn, enum LTO_tags tag)
318 { 315 {
319 unsigned HOST_WIDE_INT ix_u; 316 unsigned HOST_WIDE_INT ix_u;
320 tree result = NULL_TREE; 317 tree result = NULL_TREE;
321 318
376 373
377 /* Read and return a double-linked list of catch handlers from input 374 /* Read and return a double-linked list of catch handlers from input
378 block IB, using descriptors in DATA_IN. */ 375 block IB, using descriptors in DATA_IN. */
379 376
380 static struct eh_catch_d * 377 static struct eh_catch_d *
381 lto_input_eh_catch_list (struct lto_input_block *ib, struct data_in *data_in, 378 lto_input_eh_catch_list (class lto_input_block *ib, class data_in *data_in,
382 eh_catch *last_p) 379 eh_catch *last_p)
383 { 380 {
384 eh_catch first; 381 eh_catch first;
385 enum LTO_tags tag; 382 enum LTO_tags tag;
386 383
422 419
423 /* Read and return EH region IX from input block IB, using descriptors 420 /* Read and return EH region IX from input block IB, using descriptors
424 in DATA_IN. */ 421 in DATA_IN. */
425 422
426 static eh_region 423 static eh_region
427 input_eh_region (struct lto_input_block *ib, struct data_in *data_in, int ix) 424 input_eh_region (class lto_input_block *ib, class data_in *data_in, int ix)
428 { 425 {
429 enum LTO_tags tag; 426 enum LTO_tags tag;
430 eh_region r; 427 eh_region r;
431 428
432 /* Read the region header. */ 429 /* Read the region header. */
497 494
498 /* Read and return EH landing pad IX from input block IB, using descriptors 495 /* Read and return EH landing pad IX from input block IB, using descriptors
499 in DATA_IN. */ 496 in DATA_IN. */
500 497
501 static eh_landing_pad 498 static eh_landing_pad
502 input_eh_lp (struct lto_input_block *ib, struct data_in *data_in, int ix) 499 input_eh_lp (class lto_input_block *ib, class data_in *data_in, int ix)
503 { 500 {
504 enum LTO_tags tag; 501 enum LTO_tags tag;
505 eh_landing_pad lp; 502 eh_landing_pad lp;
506 503
507 /* Read the landing pad header. */ 504 /* Read the landing pad header. */
601 598
602 /* Read the exception table for FN from IB using the data descriptors 599 /* Read the exception table for FN from IB using the data descriptors
603 in DATA_IN. */ 600 in DATA_IN. */
604 601
605 static void 602 static void
606 input_eh_regions (struct lto_input_block *ib, struct data_in *data_in, 603 input_eh_regions (class lto_input_block *ib, class data_in *data_in,
607 struct function *fn) 604 struct function *fn)
608 { 605 {
609 HOST_WIDE_INT i, root_region, len; 606 HOST_WIDE_INT i, root_region, len;
610 enum LTO_tags tag; 607 enum LTO_tags tag;
611 608
612 tag = streamer_read_record_start (ib); 609 tag = streamer_read_record_start (ib);
613 if (tag == LTO_null) 610 if (tag == LTO_null)
614 return; 611 return;
615 612
616 lto_tag_check_range (tag, LTO_eh_table, LTO_eh_table); 613 lto_tag_check_range (tag, LTO_eh_table, LTO_eh_table);
617
618 /* If the file contains EH regions, then it was compiled with
619 -fexceptions. In that case, initialize the backend EH
620 machinery. */
621 lto_init_eh ();
622 614
623 gcc_assert (fn->eh); 615 gcc_assert (fn->eh);
624 616
625 root_region = streamer_read_hwi (ib); 617 root_region = streamer_read_hwi (ib);
626 gcc_assert (root_region == (int) root_region); 618 gcc_assert (root_region == (int) root_region);
712 704
713 705
714 /* Read the CFG for function FN from input block IB. */ 706 /* Read the CFG for function FN from input block IB. */
715 707
716 static void 708 static void
717 input_cfg (struct lto_input_block *ib, struct data_in *data_in, 709 input_cfg (class lto_input_block *ib, class data_in *data_in,
718 struct function *fn) 710 struct function *fn)
719 { 711 {
720 unsigned int bb_count; 712 unsigned int bb_count;
721 basic_block p_bb; 713 basic_block p_bb;
722 unsigned int i; 714 unsigned int i;
805 { 797 {
806 loops->larray->quick_push (NULL); 798 loops->larray->quick_push (NULL);
807 continue; 799 continue;
808 } 800 }
809 801
810 struct loop *loop = alloc_loop (); 802 class loop *loop = alloc_loop ();
811 loop->header = BASIC_BLOCK_FOR_FN (fn, header_index); 803 loop->header = BASIC_BLOCK_FOR_FN (fn, header_index);
812 loop->header->loop_father = loop; 804 loop->header->loop_father = loop;
813 805
814 /* Read everything copy_loop_info copies. */ 806 /* Read everything copy_loop_info copies. */
815 loop->estimate_state = streamer_read_enum (ib, loop_estimation, EST_LAST); 807 loop->estimate_state = streamer_read_enum (ib, loop_estimation, EST_LAST);
824 loop->nb_iterations_estimate = streamer_read_widest_int (ib); 816 loop->nb_iterations_estimate = streamer_read_widest_int (ib);
825 817
826 /* Read OMP SIMD related info. */ 818 /* Read OMP SIMD related info. */
827 loop->safelen = streamer_read_hwi (ib); 819 loop->safelen = streamer_read_hwi (ib);
828 loop->unroll = streamer_read_hwi (ib); 820 loop->unroll = streamer_read_hwi (ib);
821 loop->owned_clique = streamer_read_hwi (ib);
829 loop->dont_vectorize = streamer_read_hwi (ib); 822 loop->dont_vectorize = streamer_read_hwi (ib);
830 loop->force_vectorize = streamer_read_hwi (ib); 823 loop->force_vectorize = streamer_read_hwi (ib);
831 loop->simduid = stream_read_tree (ib, data_in); 824 loop->simduid = stream_read_tree (ib, data_in);
832 825
833 place_new_loop (fn, loop); 826 place_new_loop (fn, loop);
844 837
845 /* Read the SSA names array for function FN from DATA_IN using input 838 /* Read the SSA names array for function FN from DATA_IN using input
846 block IB. */ 839 block IB. */
847 840
848 static void 841 static void
849 input_ssa_names (struct lto_input_block *ib, struct data_in *data_in, 842 input_ssa_names (class lto_input_block *ib, class data_in *data_in,
850 struct function *fn) 843 struct function *fn)
851 { 844 {
852 unsigned int i, size; 845 unsigned int i, size;
853 846
854 size = streamer_read_uhwi (ib); 847 size = streamer_read_uhwi (ib);
897 { 890 {
898 if (STMT_UID_NOT_IN_RANGE (cedge->lto_stmt_uid)) 891 if (STMT_UID_NOT_IN_RANGE (cedge->lto_stmt_uid))
899 fatal_error (input_location, 892 fatal_error (input_location,
900 "Cgraph edge statement index out of range"); 893 "Cgraph edge statement index out of range");
901 cedge->call_stmt = as_a <gcall *> (stmts[cedge->lto_stmt_uid - 1]); 894 cedge->call_stmt = as_a <gcall *> (stmts[cedge->lto_stmt_uid - 1]);
895 cedge->lto_stmt_uid = 0;
902 if (!cedge->call_stmt) 896 if (!cedge->call_stmt)
903 fatal_error (input_location, 897 fatal_error (input_location,
904 "Cgraph edge statement index not found"); 898 "Cgraph edge statement index not found");
905 } 899 }
906 for (cedge = node->indirect_calls; cedge; cedge = cedge->next_callee) 900 for (cedge = node->indirect_calls; cedge; cedge = cedge->next_callee)
907 { 901 {
908 if (STMT_UID_NOT_IN_RANGE (cedge->lto_stmt_uid)) 902 if (STMT_UID_NOT_IN_RANGE (cedge->lto_stmt_uid))
909 fatal_error (input_location, 903 fatal_error (input_location,
910 "Cgraph edge statement index out of range"); 904 "Cgraph edge statement index out of range");
911 cedge->call_stmt = as_a <gcall *> (stmts[cedge->lto_stmt_uid - 1]); 905 cedge->call_stmt = as_a <gcall *> (stmts[cedge->lto_stmt_uid - 1]);
906 cedge->lto_stmt_uid = 0;
912 if (!cedge->call_stmt) 907 if (!cedge->call_stmt)
913 fatal_error (input_location, "Cgraph edge statement index not found"); 908 fatal_error (input_location, "Cgraph edge statement index not found");
914 } 909 }
915 for (i = 0; node->iterate_reference (i, ref); i++) 910 for (i = 0; node->iterate_reference (i, ref); i++)
916 if (ref->lto_stmt_uid) 911 if (ref->lto_stmt_uid)
917 { 912 {
918 if (STMT_UID_NOT_IN_RANGE (ref->lto_stmt_uid)) 913 if (STMT_UID_NOT_IN_RANGE (ref->lto_stmt_uid))
919 fatal_error (input_location, 914 fatal_error (input_location,
920 "Reference statement index out of range"); 915 "Reference statement index out of range");
921 ref->stmt = stmts[ref->lto_stmt_uid - 1]; 916 ref->stmt = stmts[ref->lto_stmt_uid - 1];
917 ref->lto_stmt_uid = 0;
922 if (!ref->stmt) 918 if (!ref->stmt)
923 fatal_error (input_location, "Reference statement index not found"); 919 fatal_error (input_location, "Reference statement index not found");
924 } 920 }
925 } 921 }
926 922
961 957
962 /* Input the base body of struct function FN from DATA_IN 958 /* Input the base body of struct function FN from DATA_IN
963 using input block IB. */ 959 using input block IB. */
964 960
965 static void 961 static void
966 input_struct_function_base (struct function *fn, struct data_in *data_in, 962 input_struct_function_base (struct function *fn, class data_in *data_in,
967 struct lto_input_block *ib) 963 class lto_input_block *ib)
968 { 964 {
969 struct bitpack_d bp; 965 struct bitpack_d bp;
970 int len; 966 int len;
971 967
972 /* Read the static chain and non-local goto save area. */ 968 /* Read the static chain and non-local goto save area. */
1002 fn->stdarg = bp_unpack_value (&bp, 1); 998 fn->stdarg = bp_unpack_value (&bp, 1);
1003 fn->has_nonlocal_label = bp_unpack_value (&bp, 1); 999 fn->has_nonlocal_label = bp_unpack_value (&bp, 1);
1004 fn->has_forced_label_in_static = bp_unpack_value (&bp, 1); 1000 fn->has_forced_label_in_static = bp_unpack_value (&bp, 1);
1005 fn->calls_alloca = bp_unpack_value (&bp, 1); 1001 fn->calls_alloca = bp_unpack_value (&bp, 1);
1006 fn->calls_setjmp = bp_unpack_value (&bp, 1); 1002 fn->calls_setjmp = bp_unpack_value (&bp, 1);
1003 fn->calls_eh_return = bp_unpack_value (&bp, 1);
1007 fn->has_force_vectorize_loops = bp_unpack_value (&bp, 1); 1004 fn->has_force_vectorize_loops = bp_unpack_value (&bp, 1);
1008 fn->has_simduid_loops = bp_unpack_value (&bp, 1); 1005 fn->has_simduid_loops = bp_unpack_value (&bp, 1);
1009 fn->va_list_fpr_size = bp_unpack_value (&bp, 8); 1006 fn->va_list_fpr_size = bp_unpack_value (&bp, 8);
1010 fn->va_list_gpr_size = bp_unpack_value (&bp, 8); 1007 fn->va_list_gpr_size = bp_unpack_value (&bp, 8);
1011 fn->last_clique = bp_unpack_value (&bp, sizeof (short) * 8); 1008 fn->last_clique = bp_unpack_value (&bp, sizeof (short) * 8);
1025 1022
1026 1023
1027 /* Read the body of function FN_DECL from DATA_IN using input block IB. */ 1024 /* Read the body of function FN_DECL from DATA_IN using input block IB. */
1028 1025
1029 static void 1026 static void
1030 input_function (tree fn_decl, struct data_in *data_in, 1027 input_function (tree fn_decl, class data_in *data_in,
1031 struct lto_input_block *ib, struct lto_input_block *ib_cfg) 1028 class lto_input_block *ib, class lto_input_block *ib_cfg,
1029 cgraph_node *node)
1032 { 1030 {
1033 struct function *fn; 1031 struct function *fn;
1034 enum LTO_tags tag; 1032 enum LTO_tags tag;
1035 gimple **stmts; 1033 gimple **stmts;
1036 basic_block bb; 1034 basic_block bb;
1037 struct cgraph_node *node;
1038 1035
1039 tag = streamer_read_record_start (ib); 1036 tag = streamer_read_record_start (ib);
1040 lto_tag_check (tag, LTO_function); 1037 lto_tag_check (tag, LTO_function);
1041 1038
1042 /* Read decls for parameters and args. */ 1039 /* Read decls for parameters and args. */
1068 /* We input IL in SSA form. */ 1065 /* We input IL in SSA form. */
1069 cfun->gimple_df->in_ssa_p = true; 1066 cfun->gimple_df->in_ssa_p = true;
1070 1067
1071 gimple_register_cfg_hooks (); 1068 gimple_register_cfg_hooks ();
1072 1069
1073 node = cgraph_node::get (fn_decl);
1074 if (!node)
1075 node = cgraph_node::create (fn_decl);
1076 input_struct_function_base (fn, data_in, ib); 1070 input_struct_function_base (fn, data_in, ib);
1077 input_cfg (ib_cfg, data_in, fn); 1071 input_cfg (ib_cfg, data_in, fn);
1078 1072
1079 /* Read all the SSA names. */ 1073 /* Read all the SSA names. */
1080 input_ssa_names (ib, data_in, fn); 1074 input_ssa_names (ib, data_in, fn);
1136 { 1130 {
1137 if (is_gimple_debug (stmt) 1131 if (is_gimple_debug (stmt)
1138 && (gimple_debug_nonbind_marker_p (stmt) 1132 && (gimple_debug_nonbind_marker_p (stmt)
1139 ? !MAY_HAVE_DEBUG_MARKER_STMTS 1133 ? !MAY_HAVE_DEBUG_MARKER_STMTS
1140 : !MAY_HAVE_DEBUG_BIND_STMTS)) 1134 : !MAY_HAVE_DEBUG_BIND_STMTS))
1135 remove = true;
1136 /* In case the linemap overflows locations can be dropped
1137 to zero. Thus do not keep nonsensical inline entry markers
1138 we'd later ICE on. */
1139 tree block;
1140 if (gimple_debug_inline_entry_p (stmt)
1141 && (((block = gimple_block (stmt))
1142 && !inlined_function_outer_scope_p (block))
1143 || !debug_inline_points))
1141 remove = true; 1144 remove = true;
1142 if (is_gimple_call (stmt) 1145 if (is_gimple_call (stmt)
1143 && gimple_call_internal_p (stmt)) 1146 && gimple_call_internal_p (stmt))
1144 { 1147 {
1145 bool replace = false; 1148 bool replace = false;
1219 1222
1220 update_max_bb_count (); 1223 update_max_bb_count ();
1221 fixup_call_stmt_edges (node, stmts); 1224 fixup_call_stmt_edges (node, stmts);
1222 execute_all_ipa_stmt_fixups (node, stmts); 1225 execute_all_ipa_stmt_fixups (node, stmts);
1223 1226
1224 update_ssa (TODO_update_ssa_only_virtuals);
1225 free_dominance_info (CDI_DOMINATORS); 1227 free_dominance_info (CDI_DOMINATORS);
1226 free_dominance_info (CDI_POST_DOMINATORS); 1228 free_dominance_info (CDI_POST_DOMINATORS);
1227 free (stmts); 1229 free (stmts);
1228 pop_cfun (); 1230 pop_cfun ();
1229 } 1231 }
1230 1232
1231 /* Read the body of function FN_DECL from DATA_IN using input block IB. */ 1233 /* Read the body of function FN_DECL from DATA_IN using input block IB. */
1232 1234
1233 static void 1235 static void
1234 input_constructor (tree var, struct data_in *data_in, 1236 input_constructor (tree var, class data_in *data_in,
1235 struct lto_input_block *ib) 1237 class lto_input_block *ib)
1236 { 1238 {
1237 DECL_INITIAL (var) = stream_read_tree (ib, data_in); 1239 DECL_INITIAL (var) = stream_read_tree (ib, data_in);
1238 } 1240 }
1239 1241
1240 1242
1247 static void 1249 static void
1248 lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symtab_node *node, 1250 lto_read_body_or_constructor (struct lto_file_decl_data *file_data, struct symtab_node *node,
1249 const char *data, enum lto_section_type section_type) 1251 const char *data, enum lto_section_type section_type)
1250 { 1252 {
1251 const struct lto_function_header *header; 1253 const struct lto_function_header *header;
1252 struct data_in *data_in; 1254 class data_in *data_in;
1253 int cfg_offset; 1255 int cfg_offset;
1254 int main_offset; 1256 int main_offset;
1255 int string_offset; 1257 int string_offset;
1256 tree fn_decl = node->decl; 1258 tree fn_decl = node->decl;
1257 1259
1290 file_data->mode_table); 1292 file_data->mode_table);
1291 if (TREE_CODE (node->decl) == FUNCTION_DECL) 1293 if (TREE_CODE (node->decl) == FUNCTION_DECL)
1292 { 1294 {
1293 lto_input_block ib_cfg (data + cfg_offset, header->cfg_size, 1295 lto_input_block ib_cfg (data + cfg_offset, header->cfg_size,
1294 file_data->mode_table); 1296 file_data->mode_table);
1295 input_function (fn_decl, data_in, &ib_main, &ib_cfg); 1297 input_function (fn_decl, data_in, &ib_main, &ib_cfg,
1298 dyn_cast <cgraph_node *>(node));
1296 } 1299 }
1297 else 1300 else
1298 input_constructor (fn_decl, data_in, &ib_main); 1301 input_constructor (fn_decl, data_in, &ib_main);
1299 data_in->location_cache.apply_location_cache (); 1302 data_in->location_cache.apply_location_cache ();
1300 /* And fixup types we streamed locally. */ 1303 /* And fixup types we streamed locally. */
1360 1363
1361 /* Read the physical representation of a tree node EXPR from 1364 /* Read the physical representation of a tree node EXPR from
1362 input block IB using the per-file context in DATA_IN. */ 1365 input block IB using the per-file context in DATA_IN. */
1363 1366
1364 static void 1367 static void
1365 lto_read_tree_1 (struct lto_input_block *ib, struct data_in *data_in, tree expr) 1368 lto_read_tree_1 (class lto_input_block *ib, class data_in *data_in, tree expr)
1366 { 1369 {
1367 /* Read all the bitfield values in EXPR. Note that for LTO, we 1370 /* Read all the bitfield values in EXPR. Note that for LTO, we
1368 only write language-independent bitfields, so no more unpacking is 1371 only write language-independent bitfields, so no more unpacking is
1369 needed. */ 1372 needed. */
1370 streamer_read_tree_bitfields (ib, data_in, expr); 1373 streamer_read_tree_bitfields (ib, data_in, expr);
1398 1401
1399 /* Read the physical representation of a tree node with tag TAG from 1402 /* Read the physical representation of a tree node with tag TAG from
1400 input block IB using the per-file context in DATA_IN. */ 1403 input block IB using the per-file context in DATA_IN. */
1401 1404
1402 static tree 1405 static tree
1403 lto_read_tree (struct lto_input_block *ib, struct data_in *data_in, 1406 lto_read_tree (class lto_input_block *ib, class data_in *data_in,
1404 enum LTO_tags tag, hashval_t hash) 1407 enum LTO_tags tag, hashval_t hash)
1405 { 1408 {
1406 /* Instantiate a new tree node. */ 1409 /* Instantiate a new tree node. */
1407 tree result = streamer_alloc_tree (ib, data_in, tag); 1410 tree result = streamer_alloc_tree (ib, data_in, tag);
1408 1411
1421 1424
1422 /* Populate the reader cache with trees materialized from the SCC 1425 /* Populate the reader cache with trees materialized from the SCC
1423 following in the IB, DATA_IN stream. */ 1426 following in the IB, DATA_IN stream. */
1424 1427
1425 hashval_t 1428 hashval_t
1426 lto_input_scc (struct lto_input_block *ib, struct data_in *data_in, 1429 lto_input_scc (class lto_input_block *ib, class data_in *data_in,
1427 unsigned *len, unsigned *entry_len) 1430 unsigned *len, unsigned *entry_len)
1428 { 1431 {
1429 /* A blob of unnamed tree nodes, fill the cache from it and 1432 /* A blob of unnamed tree nodes, fill the cache from it and
1430 recurse. */ 1433 recurse. */
1431 unsigned size = streamer_read_uhwi (ib); 1434 unsigned size = streamer_read_uhwi (ib);
1478 /* Read a tree from input block IB using the per-file context in 1481 /* Read a tree from input block IB using the per-file context in
1479 DATA_IN. This context is used, for example, to resolve references 1482 DATA_IN. This context is used, for example, to resolve references
1480 to previously read nodes. */ 1483 to previously read nodes. */
1481 1484
1482 tree 1485 tree
1483 lto_input_tree_1 (struct lto_input_block *ib, struct data_in *data_in, 1486 lto_input_tree_1 (class lto_input_block *ib, class data_in *data_in,
1484 enum LTO_tags tag, hashval_t hash) 1487 enum LTO_tags tag, hashval_t hash)
1485 { 1488 {
1486 tree result; 1489 tree result;
1487 1490
1488 gcc_assert ((unsigned) tag < (unsigned) LTO_NUM_TAGS); 1491 gcc_assert ((unsigned) tag < (unsigned) LTO_NUM_TAGS);
1528 1531
1529 return result; 1532 return result;
1530 } 1533 }
1531 1534
1532 tree 1535 tree
1533 lto_input_tree (struct lto_input_block *ib, struct data_in *data_in) 1536 lto_input_tree (class lto_input_block *ib, class data_in *data_in)
1534 { 1537 {
1535 enum LTO_tags tag; 1538 enum LTO_tags tag;
1536 1539
1537 /* Input and skip SCCs. */ 1540 /* Input and skip SCCs. */
1538 while ((tag = streamer_read_record_start (ib)) == LTO_tree_scc) 1541 while ((tag = streamer_read_record_start (ib)) == LTO_tree_scc)
1555 1558
1556 void 1559 void
1557 lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base) 1560 lto_input_toplevel_asms (struct lto_file_decl_data *file_data, int order_base)
1558 { 1561 {
1559 size_t len; 1562 size_t len;
1560 const char *data = lto_get_section_data (file_data, LTO_section_asm, 1563 const char *data
1561 NULL, &len); 1564 = lto_get_summary_section_data (file_data, LTO_section_asm, &len);
1562 const struct lto_simple_header_with_strings *header 1565 const struct lto_simple_header_with_strings *header
1563 = (const struct lto_simple_header_with_strings *) data; 1566 = (const struct lto_simple_header_with_strings *) data;
1564 int string_offset; 1567 int string_offset;
1565 struct data_in *data_in; 1568 class data_in *data_in;
1566 tree str; 1569 tree str;
1567 1570
1568 if (! data) 1571 if (! data)
1569 return; 1572 return;
1570 1573
1594 1597
1595 void 1598 void
1596 lto_input_mode_table (struct lto_file_decl_data *file_data) 1599 lto_input_mode_table (struct lto_file_decl_data *file_data)
1597 { 1600 {
1598 size_t len; 1601 size_t len;
1599 const char *data = lto_get_section_data (file_data, LTO_section_mode_table, 1602 const char *data
1600 NULL, &len); 1603 = lto_get_summary_section_data (file_data, LTO_section_mode_table, &len);
1601 if (! data) 1604 if (! data)
1602 { 1605 {
1603 internal_error ("cannot read LTO mode table from %s", 1606 internal_error ("cannot read LTO mode table from %s",
1604 file_data->file_name); 1607 file_data->file_name);
1605 return; 1608 return;
1608 unsigned char *table = ggc_cleared_vec_alloc<unsigned char> (1 << 8); 1611 unsigned char *table = ggc_cleared_vec_alloc<unsigned char> (1 << 8);
1609 file_data->mode_table = table; 1612 file_data->mode_table = table;
1610 const struct lto_simple_header_with_strings *header 1613 const struct lto_simple_header_with_strings *header
1611 = (const struct lto_simple_header_with_strings *) data; 1614 = (const struct lto_simple_header_with_strings *) data;
1612 int string_offset; 1615 int string_offset;
1613 struct data_in *data_in; 1616 class data_in *data_in;
1614 string_offset = sizeof (*header) + header->main_size; 1617 string_offset = sizeof (*header) + header->main_size;
1615 1618
1616 lto_input_block ib (data + sizeof (*header), header->main_size, NULL); 1619 lto_input_block ib (data + sizeof (*header), header->main_size, NULL);
1617 data_in = lto_data_in_create (file_data, data + string_offset, 1620 data_in = lto_data_in_create (file_data, data + string_offset,
1618 header->string_size, vNULL); 1621 header->string_size, vNULL);
1697 table[m] = BLKmode; 1700 table[m] = BLKmode;
1698 break; 1701 break;
1699 } 1702 }
1700 /* FALLTHRU */ 1703 /* FALLTHRU */
1701 default: 1704 default:
1702 fatal_error (UNKNOWN_LOCATION, "unsupported mode %s\n", mname); 1705 /* This is only used for offloading-target compilations and
1706 is a user-facing error. Give a better error message for
1707 the common modes; see also mode-classes.def. */
1708 if (mclass == MODE_FLOAT)
1709 fatal_error (UNKNOWN_LOCATION,
1710 "%s - %u-bit-precision floating-point numbers "
1711 "unsupported (mode %qs)", TARGET_MACHINE,
1712 prec.to_constant (), mname);
1713 else if (mclass == MODE_DECIMAL_FLOAT)
1714 fatal_error (UNKNOWN_LOCATION,
1715 "%s - %u-bit-precision decimal floating-point "
1716 "numbers unsupported (mode %qs)", TARGET_MACHINE,
1717 prec.to_constant (), mname);
1718 else if (mclass == MODE_COMPLEX_FLOAT)
1719 fatal_error (UNKNOWN_LOCATION,
1720 "%s - %u-bit-precision complex floating-point "
1721 "numbers unsupported (mode %qs)", TARGET_MACHINE,
1722 prec.to_constant (), mname);
1723 else if (mclass == MODE_INT)
1724 fatal_error (UNKNOWN_LOCATION,
1725 "%s - %u-bit integer numbers unsupported (mode "
1726 "%qs)", TARGET_MACHINE, prec.to_constant (), mname);
1727 else
1728 fatal_error (UNKNOWN_LOCATION, "%s - unsupported mode %qs",
1729 TARGET_MACHINE, mname);
1703 break; 1730 break;
1704 } 1731 }
1705 } 1732 }
1706 } 1733 }
1707 lto_data_in_delete (data_in); 1734 lto_data_in_delete (data_in);
1715 void 1742 void
1716 lto_reader_init (void) 1743 lto_reader_init (void)
1717 { 1744 {
1718 lto_streamer_init (); 1745 lto_streamer_init ();
1719 file_name_hash_table 1746 file_name_hash_table
1720 = new hash_table<freeing_string_slot_hasher> (37); 1747 = new hash_table<string_slot_hasher> (37);
1748 string_slot_allocator = new object_allocator <struct string_slot>
1749 ("line map file name hash");
1750 gcc_obstack_init (&file_name_obstack);
1751 }
1752
1753 /* Free hash table used to stream in location file names. */
1754
1755 void
1756 lto_free_file_name_hash (void)
1757 {
1758 delete file_name_hash_table;
1759 file_name_hash_table = NULL;
1760 delete string_slot_allocator;
1761 string_slot_allocator = NULL;
1762 /* file_name_obstack must stay allocated since it is referred to by
1763 line map table. */
1721 } 1764 }
1722 1765
1723 1766
1724 /* Create a new data_in object for FILE_DATA. STRINGS is the string 1767 /* Create a new data_in object for FILE_DATA. STRINGS is the string
1725 table to use with LEN strings. RESOLUTIONS is the vector of linker 1768 table to use with LEN strings. RESOLUTIONS is the vector of linker
1726 resolutions (NULL if not using a linker plugin). */ 1769 resolutions (NULL if not using a linker plugin). */
1727 1770
1728 struct data_in * 1771 class data_in *
1729 lto_data_in_create (struct lto_file_decl_data *file_data, const char *strings, 1772 lto_data_in_create (struct lto_file_decl_data *file_data, const char *strings,
1730 unsigned len, 1773 unsigned len,
1731 vec<ld_plugin_symbol_resolution_t> resolutions) 1774 vec<ld_plugin_symbol_resolution_t> resolutions)
1732 { 1775 {
1733 struct data_in *data_in = new (struct data_in); 1776 class data_in *data_in = new (class data_in);
1734 data_in->file_data = file_data; 1777 data_in->file_data = file_data;
1735 data_in->strings = strings; 1778 data_in->strings = strings;
1736 data_in->strings_len = len; 1779 data_in->strings_len = len;
1737 data_in->globals_resolution = resolutions; 1780 data_in->globals_resolution = resolutions;
1738 data_in->reader_cache = streamer_tree_cache_create (false, false, true); 1781 data_in->reader_cache = streamer_tree_cache_create (false, false, true);
1741 1784
1742 1785
1743 /* Remove DATA_IN. */ 1786 /* Remove DATA_IN. */
1744 1787
1745 void 1788 void
1746 lto_data_in_delete (struct data_in *data_in) 1789 lto_data_in_delete (class data_in *data_in)
1747 { 1790 {
1748 data_in->globals_resolution.release (); 1791 data_in->globals_resolution.release ();
1749 streamer_tree_cache_delete (data_in->reader_cache); 1792 streamer_tree_cache_delete (data_in->reader_cache);
1750 delete data_in; 1793 delete data_in;
1751 } 1794 }