Mercurial > hg > CbC > CbC_gcc
comparison gcc/lto-streamer-in.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
353 case LTO_global_decl_ref: | 353 case LTO_global_decl_ref: |
354 case LTO_result_decl_ref: | 354 case LTO_result_decl_ref: |
355 case LTO_const_decl_ref: | 355 case LTO_const_decl_ref: |
356 case LTO_imported_decl_ref: | 356 case LTO_imported_decl_ref: |
357 case LTO_label_decl_ref: | 357 case LTO_label_decl_ref: |
358 case LTO_translation_unit_decl_ref: | |
358 ix_u = lto_input_uleb128 (ib); | 359 ix_u = lto_input_uleb128 (ib); |
359 result = lto_file_decl_data_get_var_decl (data_in->file_data, ix_u); | 360 result = lto_file_decl_data_get_var_decl (data_in->file_data, ix_u); |
360 break; | 361 break; |
361 | 362 |
362 default: | 363 default: |
387 eh_catch n; | 388 eh_catch n; |
388 | 389 |
389 lto_tag_check_range (tag, LTO_eh_catch, LTO_eh_catch); | 390 lto_tag_check_range (tag, LTO_eh_catch, LTO_eh_catch); |
390 | 391 |
391 /* Read the catch node. */ | 392 /* Read the catch node. */ |
392 n = GGC_CNEW (struct eh_catch_d); | 393 n = ggc_alloc_cleared_eh_catch_d (); |
393 n->type_list = lto_input_tree (ib, data_in); | 394 n->type_list = lto_input_tree (ib, data_in); |
394 n->filter_list = lto_input_tree (ib, data_in); | 395 n->filter_list = lto_input_tree (ib, data_in); |
395 n->label = lto_input_tree (ib, data_in); | 396 n->label = lto_input_tree (ib, data_in); |
396 | 397 |
397 /* Register all the types in N->FILTER_LIST. */ | 398 /* Register all the types in N->FILTER_LIST. */ |
427 /* Read the region header. */ | 428 /* Read the region header. */ |
428 tag = input_record_start (ib); | 429 tag = input_record_start (ib); |
429 if (tag == LTO_null) | 430 if (tag == LTO_null) |
430 return NULL; | 431 return NULL; |
431 | 432 |
432 r = GGC_CNEW (struct eh_region_d); | 433 r = ggc_alloc_cleared_eh_region_d (); |
433 r->index = lto_input_sleb128 (ib); | 434 r->index = lto_input_sleb128 (ib); |
434 | 435 |
435 gcc_assert (r->index == ix); | 436 gcc_assert (r->index == ix); |
436 | 437 |
437 /* Read all the region pointers as region numbers. We'll fix up | 438 /* Read all the region pointers as region numbers. We'll fix up |
500 if (tag == LTO_null) | 501 if (tag == LTO_null) |
501 return NULL; | 502 return NULL; |
502 | 503 |
503 lto_tag_check_range (tag, LTO_eh_landing_pad, LTO_eh_landing_pad); | 504 lto_tag_check_range (tag, LTO_eh_landing_pad, LTO_eh_landing_pad); |
504 | 505 |
505 lp = GGC_CNEW (struct eh_landing_pad_d); | 506 lp = ggc_alloc_cleared_eh_landing_pad_d (); |
506 lp->index = lto_input_sleb128 (ib); | 507 lp->index = lto_input_sleb128 (ib); |
507 gcc_assert (lp->index == ix); | 508 gcc_assert (lp->index == ix); |
508 lp->next_lp = (eh_landing_pad) (intptr_t) lto_input_sleb128 (ib); | 509 lp->next_lp = (eh_landing_pad) (intptr_t) lto_input_sleb128 (ib); |
509 lp->region = (eh_region) (intptr_t) lto_input_sleb128 (ib); | 510 lp->region = (eh_region) (intptr_t) lto_input_sleb128 (ib); |
510 lp->post_landing_pad = lto_input_tree (ib, data_in); | 511 lp->post_landing_pad = lto_input_tree (ib, data_in); |
537 #define FIXUP_EH_LP(p) (p) = VEC_index (eh_landing_pad, lp_array, \ | 538 #define FIXUP_EH_LP(p) (p) = VEC_index (eh_landing_pad, lp_array, \ |
538 (HOST_WIDE_INT) (intptr_t) (p)) | 539 (HOST_WIDE_INT) (intptr_t) (p)) |
539 | 540 |
540 /* Convert all the index numbers stored in pointer fields into | 541 /* Convert all the index numbers stored in pointer fields into |
541 pointers to the corresponding slots in the EH region array. */ | 542 pointers to the corresponding slots in the EH region array. */ |
542 for (i = 0; VEC_iterate (eh_region, eh_array, i, r); i++) | 543 FOR_EACH_VEC_ELT (eh_region, eh_array, i, r) |
543 { | 544 { |
544 /* The array may contain NULL regions. */ | 545 /* The array may contain NULL regions. */ |
545 if (r == NULL) | 546 if (r == NULL) |
546 continue; | 547 continue; |
547 | 548 |
552 FIXUP_EH_LP (r->landing_pads); | 553 FIXUP_EH_LP (r->landing_pads); |
553 } | 554 } |
554 | 555 |
555 /* Convert all the index numbers stored in pointer fields into | 556 /* Convert all the index numbers stored in pointer fields into |
556 pointers to the corresponding slots in the EH landing pad array. */ | 557 pointers to the corresponding slots in the EH landing pad array. */ |
557 for (i = 0; VEC_iterate (eh_landing_pad, lp_array, i, lp); i++) | 558 FOR_EACH_VEC_ELT (eh_landing_pad, lp_array, i, lp) |
558 { | 559 { |
559 /* The array may contain NULL landing pads. */ | 560 /* The array may contain NULL landing pads. */ |
560 if (lp == NULL) | 561 if (lp == NULL) |
561 continue; | 562 continue; |
562 | 563 |
705 make_new_block (struct function *fn, unsigned int index) | 706 make_new_block (struct function *fn, unsigned int index) |
706 { | 707 { |
707 basic_block bb = alloc_block (); | 708 basic_block bb = alloc_block (); |
708 bb->index = index; | 709 bb->index = index; |
709 SET_BASIC_BLOCK_FOR_FUNCTION (fn, index, bb); | 710 SET_BASIC_BLOCK_FOR_FUNCTION (fn, index, bb); |
710 bb->il.gimple = GGC_CNEW (struct gimple_bb_info); | 711 bb->il.gimple = ggc_alloc_cleared_gimple_bb_info (); |
711 n_basic_blocks_for_function (fn)++; | 712 n_basic_blocks_for_function (fn)++; |
712 bb->flags = 0; | 713 bb->flags = 0; |
713 set_bb_seq (bb, gimple_seq_alloc ()); | 714 set_bb_seq (bb, gimple_seq_alloc ()); |
714 return bb; | 715 return bb; |
715 } | 716 } |
716 | 717 |
717 | 718 |
718 /* Read the CFG for function FN from input block IB. */ | 719 /* Read the CFG for function FN from input block IB. */ |
719 | 720 |
720 static void | 721 static void |
721 input_cfg (struct lto_input_block *ib, struct function *fn) | 722 input_cfg (struct lto_input_block *ib, struct function *fn, |
723 int count_materialization_scale) | |
722 { | 724 { |
723 unsigned int bb_count; | 725 unsigned int bb_count; |
724 basic_block p_bb; | 726 basic_block p_bb; |
725 unsigned int i; | 727 unsigned int i; |
726 int index; | 728 int index; |
763 gcov_type count; | 765 gcov_type count; |
764 edge e; | 766 edge e; |
765 | 767 |
766 dest_index = lto_input_uleb128 (ib); | 768 dest_index = lto_input_uleb128 (ib); |
767 probability = (int) lto_input_sleb128 (ib); | 769 probability = (int) lto_input_sleb128 (ib); |
768 count = (gcov_type) lto_input_sleb128 (ib); | 770 count = ((gcov_type) lto_input_sleb128 (ib) * count_materialization_scale |
771 + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE; | |
769 edge_flags = lto_input_uleb128 (ib); | 772 edge_flags = lto_input_uleb128 (ib); |
770 | 773 |
771 dest = BASIC_BLOCK_FOR_FUNCTION (fn, dest_index); | 774 dest = BASIC_BLOCK_FOR_FUNCTION (fn, dest_index); |
772 | 775 |
773 if (dest == NULL) | 776 if (dest == NULL) |
870 | 873 |
871 i = lto_input_uleb128 (ib); | 874 i = lto_input_uleb128 (ib); |
872 } | 875 } |
873 } | 876 } |
874 | 877 |
875 | |
876 /* Fixup the reference tree OP for replaced VAR_DECLs with mismatched | |
877 types. */ | |
878 | |
879 static void | |
880 maybe_fixup_handled_component (tree op) | |
881 { | |
882 tree decl_type; | |
883 tree wanted_type; | |
884 | |
885 while (handled_component_p (TREE_OPERAND (op, 0))) | |
886 op = TREE_OPERAND (op, 0); | |
887 if (TREE_CODE (TREE_OPERAND (op, 0)) != VAR_DECL) | |
888 return; | |
889 | |
890 decl_type = TREE_TYPE (TREE_OPERAND (op, 0)); | |
891 | |
892 switch (TREE_CODE (op)) | |
893 { | |
894 case COMPONENT_REF: | |
895 /* The DECL_CONTEXT of the field-decl is the record type we look for. */ | |
896 wanted_type = DECL_CONTEXT (TREE_OPERAND (op, 1)); | |
897 break; | |
898 | |
899 case ARRAY_REF: | |
900 if (TREE_CODE (decl_type) == ARRAY_TYPE | |
901 && (TREE_TYPE (decl_type) == TREE_TYPE (op) | |
902 || useless_type_conversion_p (TREE_TYPE (op), | |
903 TREE_TYPE (decl_type)))) | |
904 return; | |
905 /* An unknown size array type should be ok. But we do not | |
906 lower the lower bound in all cases - ugh. */ | |
907 wanted_type = build_array_type (TREE_TYPE (op), NULL_TREE); | |
908 break; | |
909 | |
910 case ARRAY_RANGE_REF: | |
911 if (TREE_CODE (decl_type) == ARRAY_TYPE | |
912 && (TREE_TYPE (decl_type) == TREE_TYPE (TREE_TYPE (op)) | |
913 || useless_type_conversion_p (TREE_TYPE (TREE_TYPE (op)), | |
914 TREE_TYPE (decl_type)))) | |
915 return; | |
916 /* An unknown size array type should be ok. But we do not | |
917 lower the lower bound in all cases - ugh. */ | |
918 wanted_type = build_array_type (TREE_TYPE (TREE_TYPE (op)), NULL_TREE); | |
919 break; | |
920 | |
921 case BIT_FIELD_REF: | |
922 case VIEW_CONVERT_EXPR: | |
923 /* Very nice - nothing to do. */ | |
924 return; | |
925 | |
926 case REALPART_EXPR: | |
927 case IMAGPART_EXPR: | |
928 if (TREE_CODE (decl_type) == COMPLEX_TYPE | |
929 && (TREE_TYPE (decl_type) == TREE_TYPE (op) | |
930 || useless_type_conversion_p (TREE_TYPE (op), | |
931 TREE_TYPE (decl_type)))) | |
932 return; | |
933 wanted_type = build_complex_type (TREE_TYPE (op)); | |
934 break; | |
935 | |
936 default: | |
937 gcc_unreachable (); | |
938 } | |
939 | |
940 if (!useless_type_conversion_p (wanted_type, decl_type)) | |
941 TREE_OPERAND (op, 0) = build1 (VIEW_CONVERT_EXPR, wanted_type, | |
942 TREE_OPERAND (op, 0)); | |
943 } | |
944 | |
945 /* Fixup reference tree operands for substituted prevailing decls | |
946 with mismatched types in STMT. This handles plain DECLs where | |
947 we need the stmt for context to lookup the required type. */ | |
948 | |
949 static void | |
950 maybe_fixup_decls (gimple stmt) | |
951 { | |
952 /* We have to fixup replaced decls here in case there were | |
953 inter-TU type mismatches. Catch the most common cases | |
954 for now - this way we'll get testcases for the rest as | |
955 the type verifier will complain. */ | |
956 if (gimple_assign_single_p (stmt)) | |
957 { | |
958 tree lhs = gimple_assign_lhs (stmt); | |
959 tree rhs = gimple_assign_rhs1 (stmt); | |
960 | |
961 /* First catch loads and aggregate copies by adjusting the rhs. */ | |
962 if (TREE_CODE (rhs) == VAR_DECL) | |
963 { | |
964 if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) | |
965 gimple_assign_set_rhs1 (stmt, build1 (VIEW_CONVERT_EXPR, | |
966 TREE_TYPE (lhs), rhs)); | |
967 } | |
968 /* Then catch scalar stores. */ | |
969 else if (TREE_CODE (lhs) == VAR_DECL) | |
970 { | |
971 if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) | |
972 gimple_assign_set_lhs (stmt, build1 (VIEW_CONVERT_EXPR, | |
973 TREE_TYPE (rhs), lhs)); | |
974 } | |
975 } | |
976 else if (is_gimple_call (stmt)) | |
977 { | |
978 tree lhs = gimple_call_lhs (stmt); | |
979 | |
980 if (lhs && TREE_CODE (lhs) == VAR_DECL) | |
981 { | |
982 if (!useless_type_conversion_p (TREE_TYPE (lhs), | |
983 gimple_call_return_type (stmt))) | |
984 gimple_call_set_lhs (stmt, build1 (VIEW_CONVERT_EXPR, | |
985 gimple_call_return_type (stmt), | |
986 lhs)); | |
987 } | |
988 | |
989 /* Arguments, especially for varargs functions will be funny... */ | |
990 } | |
991 } | |
992 | |
993 /* Read a statement with tag TAG in function FN from block IB using | 878 /* Read a statement with tag TAG in function FN from block IB using |
994 descriptors in DATA_IN. */ | 879 descriptors in DATA_IN. */ |
995 | 880 |
996 static gimple | 881 static gimple |
997 input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in, | 882 input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in, |
999 { | 884 { |
1000 gimple stmt; | 885 gimple stmt; |
1001 enum gimple_code code; | 886 enum gimple_code code; |
1002 unsigned HOST_WIDE_INT num_ops; | 887 unsigned HOST_WIDE_INT num_ops; |
1003 size_t i; | 888 size_t i; |
1004 struct bitpack_d *bp; | 889 struct bitpack_d bp; |
1005 | 890 |
1006 code = lto_tag_to_gimple_code (tag); | 891 code = lto_tag_to_gimple_code (tag); |
1007 | 892 |
1008 /* Read the tuple header. */ | 893 /* Read the tuple header. */ |
1009 bp = lto_input_bitpack (ib); | 894 bp = lto_input_bitpack (ib); |
1010 num_ops = bp_unpack_value (bp, sizeof (unsigned) * 8); | 895 num_ops = bp_unpack_value (&bp, sizeof (unsigned) * 8); |
1011 stmt = gimple_alloc (code, num_ops); | 896 stmt = gimple_alloc (code, num_ops); |
1012 stmt->gsbase.no_warning = bp_unpack_value (bp, 1); | 897 stmt->gsbase.no_warning = bp_unpack_value (&bp, 1); |
1013 if (is_gimple_assign (stmt)) | 898 if (is_gimple_assign (stmt)) |
1014 stmt->gsbase.nontemporal_move = bp_unpack_value (bp, 1); | 899 stmt->gsbase.nontemporal_move = bp_unpack_value (&bp, 1); |
1015 stmt->gsbase.has_volatile_ops = bp_unpack_value (bp, 1); | 900 stmt->gsbase.has_volatile_ops = bp_unpack_value (&bp, 1); |
1016 stmt->gsbase.subcode = bp_unpack_value (bp, 16); | 901 stmt->gsbase.subcode = bp_unpack_value (&bp, 16); |
1017 bitpack_delete (bp); | |
1018 | 902 |
1019 /* Read location information. */ | 903 /* Read location information. */ |
1020 gimple_set_location (stmt, lto_input_location (ib, data_in)); | 904 gimple_set_location (stmt, lto_input_location (ib, data_in)); |
1021 | 905 |
1022 /* Read lexical block reference. */ | 906 /* Read lexical block reference. */ |
1063 tree op = lto_input_tree (ib, data_in); | 947 tree op = lto_input_tree (ib, data_in); |
1064 gimple_set_op (stmt, i, op); | 948 gimple_set_op (stmt, i, op); |
1065 if (!op) | 949 if (!op) |
1066 continue; | 950 continue; |
1067 | 951 |
1068 /* Fixup reference tree operands for substituted prevailing decls | |
1069 with mismatched types. For plain VAR_DECLs we need to look | |
1070 at context to determine the wanted type - we do that below | |
1071 after the stmt is completed. */ | |
1072 if (TREE_CODE (op) == ADDR_EXPR | |
1073 && TREE_CODE (TREE_OPERAND (op, 0)) == VAR_DECL | |
1074 && !useless_type_conversion_p (TREE_TYPE (TREE_TYPE (op)), | |
1075 TREE_TYPE (op))) | |
1076 { | |
1077 TREE_OPERAND (op, 0) | |
1078 = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (TREE_TYPE (op)), | |
1079 TREE_OPERAND (op, 0)); | |
1080 continue; | |
1081 } | |
1082 | |
1083 /* Fixup FIELD_DECLs in COMPONENT_REFs, they are not handled | 952 /* Fixup FIELD_DECLs in COMPONENT_REFs, they are not handled |
1084 by decl merging. */ | 953 by decl merging. */ |
1085 if (TREE_CODE (op) == ADDR_EXPR) | 954 if (TREE_CODE (op) == ADDR_EXPR) |
1086 op = TREE_OPERAND (op, 0); | 955 op = TREE_OPERAND (op, 0); |
1087 while (handled_component_p (op)) | 956 while (handled_component_p (op)) |
1088 { | 957 { |
1089 if (TREE_CODE (op) == COMPONENT_REF) | 958 if (TREE_CODE (op) == COMPONENT_REF) |
1090 { | 959 { |
1091 tree field, type, tem; | 960 tree field, type, tem; |
961 tree closest_match = NULL_TREE; | |
1092 field = TREE_OPERAND (op, 1); | 962 field = TREE_OPERAND (op, 1); |
1093 type = DECL_CONTEXT (field); | 963 type = DECL_CONTEXT (field); |
1094 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) | 964 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) |
1095 { | 965 { |
1096 if (tem == field | 966 if (tem == field) |
1097 || (TREE_TYPE (tem) == TREE_TYPE (field) | |
1098 && DECL_NONADDRESSABLE_P (tem) | |
1099 == DECL_NONADDRESSABLE_P (field) | |
1100 && gimple_compare_field_offset (tem, field))) | |
1101 break; | 967 break; |
968 if (DECL_NONADDRESSABLE_P (tem) | |
969 == DECL_NONADDRESSABLE_P (field) | |
970 && gimple_compare_field_offset (tem, field)) | |
971 { | |
972 if (types_compatible_p (TREE_TYPE (tem), | |
973 TREE_TYPE (field))) | |
974 break; | |
975 else | |
976 closest_match = tem; | |
977 } | |
1102 } | 978 } |
1103 /* In case of type mismatches across units we can fail | 979 /* In case of type mismatches across units we can fail |
1104 to unify some types and thus not find a proper | 980 to unify some types and thus not find a proper |
1105 field-decl here. So only assert here if checking | 981 field-decl here. */ |
1106 is enabled. */ | 982 if (tem == NULL_TREE) |
1107 #ifdef ENABLE_CHECKING | 983 { |
1108 gcc_assert (tem != NULL_TREE); | 984 /* Thus, emit a ODR violation warning. */ |
1109 #endif | 985 if (warning_at (gimple_location (stmt), 0, |
1110 if (tem != NULL_TREE) | 986 "use of type %<%E%> with two mismatching " |
987 "declarations at field %<%E%>", | |
988 type, TREE_OPERAND (op, 1))) | |
989 { | |
990 if (TYPE_FIELDS (type)) | |
991 inform (DECL_SOURCE_LOCATION (TYPE_FIELDS (type)), | |
992 "original type declared here"); | |
993 inform (DECL_SOURCE_LOCATION (TREE_OPERAND (op, 1)), | |
994 "field in mismatching type declared here"); | |
995 if (TYPE_NAME (TREE_TYPE (field)) | |
996 && (TREE_CODE (TYPE_NAME (TREE_TYPE (field))) | |
997 == TYPE_DECL)) | |
998 inform (DECL_SOURCE_LOCATION | |
999 (TYPE_NAME (TREE_TYPE (field))), | |
1000 "type of field declared here"); | |
1001 if (closest_match | |
1002 && TYPE_NAME (TREE_TYPE (closest_match)) | |
1003 && (TREE_CODE (TYPE_NAME | |
1004 (TREE_TYPE (closest_match))) == TYPE_DECL)) | |
1005 inform (DECL_SOURCE_LOCATION | |
1006 (TYPE_NAME (TREE_TYPE (closest_match))), | |
1007 "type of mismatching field declared here"); | |
1008 } | |
1009 /* And finally fixup the types. */ | |
1010 TREE_OPERAND (op, 0) | |
1011 = build1 (VIEW_CONVERT_EXPR, type, | |
1012 TREE_OPERAND (op, 0)); | |
1013 } | |
1014 else | |
1111 TREE_OPERAND (op, 1) = tem; | 1015 TREE_OPERAND (op, 1) = tem; |
1112 } | 1016 } |
1113 | 1017 |
1114 /* Preserve the last handled component for the fixup of | |
1115 its operand below. */ | |
1116 if (!handled_component_p (TREE_OPERAND (op, 0))) | |
1117 break; | |
1118 op = TREE_OPERAND (op, 0); | 1018 op = TREE_OPERAND (op, 0); |
1119 } | 1019 } |
1120 | |
1121 /* Fixup reference tree operands for substituted prevailing decls | |
1122 with mismatched types. */ | |
1123 if (handled_component_p (op)) | |
1124 maybe_fixup_handled_component (op); | |
1125 } | 1020 } |
1126 break; | 1021 break; |
1127 | 1022 |
1128 case GIMPLE_NOP: | 1023 case GIMPLE_NOP: |
1129 case GIMPLE_PREDICT: | 1024 case GIMPLE_PREDICT: |
1159 | 1054 |
1160 /* Reset alias information. */ | 1055 /* Reset alias information. */ |
1161 if (code == GIMPLE_CALL) | 1056 if (code == GIMPLE_CALL) |
1162 gimple_call_reset_alias_info (stmt); | 1057 gimple_call_reset_alias_info (stmt); |
1163 | 1058 |
1164 /* Fixup reference tree operands for substituted prevailing decls | |
1165 with mismatched types. */ | |
1166 maybe_fixup_decls (stmt); | |
1167 | |
1168 /* Mark the statement modified so its operand vectors can be filled in. */ | 1059 /* Mark the statement modified so its operand vectors can be filled in. */ |
1169 gimple_set_modified (stmt, true); | 1060 gimple_set_modified (stmt, true); |
1170 | 1061 |
1171 return stmt; | 1062 return stmt; |
1172 } | 1063 } |
1175 /* Read a basic block with tag TAG from DATA_IN using input block IB. | 1066 /* Read a basic block with tag TAG from DATA_IN using input block IB. |
1176 FN is the function being processed. */ | 1067 FN is the function being processed. */ |
1177 | 1068 |
1178 static void | 1069 static void |
1179 input_bb (struct lto_input_block *ib, enum LTO_tags tag, | 1070 input_bb (struct lto_input_block *ib, enum LTO_tags tag, |
1180 struct data_in *data_in, struct function *fn) | 1071 struct data_in *data_in, struct function *fn, |
1072 int count_materialization_scale) | |
1181 { | 1073 { |
1182 unsigned int index; | 1074 unsigned int index; |
1183 basic_block bb; | 1075 basic_block bb; |
1184 gimple_stmt_iterator bsi; | 1076 gimple_stmt_iterator bsi; |
1185 | 1077 |
1188 gcc_assert (cfun == fn); | 1080 gcc_assert (cfun == fn); |
1189 | 1081 |
1190 index = lto_input_uleb128 (ib); | 1082 index = lto_input_uleb128 (ib); |
1191 bb = BASIC_BLOCK_FOR_FUNCTION (fn, index); | 1083 bb = BASIC_BLOCK_FOR_FUNCTION (fn, index); |
1192 | 1084 |
1193 bb->count = lto_input_sleb128 (ib); | 1085 bb->count = (lto_input_sleb128 (ib) * count_materialization_scale |
1086 + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE; | |
1194 bb->loop_depth = lto_input_sleb128 (ib); | 1087 bb->loop_depth = lto_input_sleb128 (ib); |
1195 bb->frequency = lto_input_sleb128 (ib); | 1088 bb->frequency = lto_input_sleb128 (ib); |
1196 bb->flags = lto_input_sleb128 (ib); | 1089 bb->flags = lto_input_sleb128 (ib); |
1197 | 1090 |
1198 /* LTO_bb1 has statements. LTO_bb0 does not. */ | 1091 /* LTO_bb1 has statements. LTO_bb0 does not. */ |
1202 bsi = gsi_start_bb (bb); | 1095 bsi = gsi_start_bb (bb); |
1203 tag = input_record_start (ib); | 1096 tag = input_record_start (ib); |
1204 while (tag) | 1097 while (tag) |
1205 { | 1098 { |
1206 gimple stmt = input_gimple_stmt (ib, data_in, fn, tag); | 1099 gimple stmt = input_gimple_stmt (ib, data_in, fn, tag); |
1207 | 1100 if (!is_gimple_debug (stmt)) |
1208 /* Change debug stmts to nops on-the-fly if we do not have VTA enabled. | 1101 find_referenced_vars_in (stmt); |
1209 This allows us to build for example static libs with debugging | |
1210 enabled and do the final link without. */ | |
1211 if (!MAY_HAVE_DEBUG_STMTS | |
1212 && is_gimple_debug (stmt)) | |
1213 stmt = gimple_build_nop (); | |
1214 | |
1215 find_referenced_vars_in (stmt); | |
1216 gsi_insert_after (&bsi, stmt, GSI_NEW_STMT); | 1102 gsi_insert_after (&bsi, stmt, GSI_NEW_STMT); |
1217 | 1103 |
1218 /* After the statement, expect a 0 delimiter or the EH region | 1104 /* After the statement, expect a 0 delimiter or the EH region |
1219 that the previous statement belongs to. */ | 1105 that the previous statement belongs to. */ |
1220 tag = input_record_start (ib); | 1106 tag = input_record_start (ib); |
1289 { | 1175 { |
1290 struct function *fn; | 1176 struct function *fn; |
1291 enum LTO_tags tag; | 1177 enum LTO_tags tag; |
1292 gimple *stmts; | 1178 gimple *stmts; |
1293 basic_block bb; | 1179 basic_block bb; |
1294 struct bitpack_d *bp; | 1180 struct bitpack_d bp; |
1295 struct cgraph_node *node; | 1181 struct cgraph_node *node; |
1296 tree args, narg, oarg; | 1182 tree args, narg, oarg; |
1183 int len; | |
1297 | 1184 |
1298 fn = DECL_STRUCT_FUNCTION (fn_decl); | 1185 fn = DECL_STRUCT_FUNCTION (fn_decl); |
1299 tag = input_record_start (ib); | 1186 tag = input_record_start (ib); |
1300 clear_line_info (data_in); | 1187 clear_line_info (data_in); |
1301 | 1188 |
1302 gimple_register_cfg_hooks (); | 1189 gimple_register_cfg_hooks (); |
1303 lto_tag_check (tag, LTO_function); | 1190 lto_tag_check (tag, LTO_function); |
1304 | 1191 |
1305 /* Read all the attributes for FN. */ | 1192 /* Read all the attributes for FN. */ |
1306 bp = lto_input_bitpack (ib); | 1193 bp = lto_input_bitpack (ib); |
1307 fn->is_thunk = bp_unpack_value (bp, 1); | 1194 fn->is_thunk = bp_unpack_value (&bp, 1); |
1308 fn->has_local_explicit_reg_vars = bp_unpack_value (bp, 1); | 1195 fn->has_local_explicit_reg_vars = bp_unpack_value (&bp, 1); |
1309 fn->after_tree_profile = bp_unpack_value (bp, 1); | 1196 fn->after_tree_profile = bp_unpack_value (&bp, 1); |
1310 fn->returns_pcc_struct = bp_unpack_value (bp, 1); | 1197 fn->returns_pcc_struct = bp_unpack_value (&bp, 1); |
1311 fn->returns_struct = bp_unpack_value (bp, 1); | 1198 fn->returns_struct = bp_unpack_value (&bp, 1); |
1312 fn->always_inline_functions_inlined = bp_unpack_value (bp, 1); | 1199 fn->can_throw_non_call_exceptions = bp_unpack_value (&bp, 1); |
1313 fn->after_inlining = bp_unpack_value (bp, 1); | 1200 fn->always_inline_functions_inlined = bp_unpack_value (&bp, 1); |
1314 fn->dont_save_pending_sizes_p = bp_unpack_value (bp, 1); | 1201 fn->after_inlining = bp_unpack_value (&bp, 1); |
1315 fn->stdarg = bp_unpack_value (bp, 1); | 1202 fn->dont_save_pending_sizes_p = bp_unpack_value (&bp, 1); |
1316 fn->has_nonlocal_label = bp_unpack_value (bp, 1); | 1203 fn->stdarg = bp_unpack_value (&bp, 1); |
1317 fn->calls_alloca = bp_unpack_value (bp, 1); | 1204 fn->has_nonlocal_label = bp_unpack_value (&bp, 1); |
1318 fn->calls_setjmp = bp_unpack_value (bp, 1); | 1205 fn->calls_alloca = bp_unpack_value (&bp, 1); |
1319 fn->va_list_fpr_size = bp_unpack_value (bp, 8); | 1206 fn->calls_setjmp = bp_unpack_value (&bp, 1); |
1320 fn->va_list_gpr_size = bp_unpack_value (bp, 8); | 1207 fn->va_list_fpr_size = bp_unpack_value (&bp, 8); |
1321 bitpack_delete (bp); | 1208 fn->va_list_gpr_size = bp_unpack_value (&bp, 8); |
1209 | |
1210 /* Input the function start and end loci. */ | |
1211 fn->function_start_locus = lto_input_location (ib, data_in); | |
1212 fn->function_end_locus = lto_input_location (ib, data_in); | |
1322 | 1213 |
1323 /* Input the current IL state of the function. */ | 1214 /* Input the current IL state of the function. */ |
1324 fn->curr_properties = lto_input_uleb128 (ib); | 1215 fn->curr_properties = lto_input_uleb128 (ib); |
1325 | 1216 |
1326 /* Read the static chain and non-local goto save area. */ | 1217 /* Read the static chain and non-local goto save area. */ |
1327 fn->static_chain_decl = lto_input_tree (ib, data_in); | 1218 fn->static_chain_decl = lto_input_tree (ib, data_in); |
1328 fn->nonlocal_goto_save_area = lto_input_tree (ib, data_in); | 1219 fn->nonlocal_goto_save_area = lto_input_tree (ib, data_in); |
1329 | 1220 |
1330 /* Read all the local symbols. */ | 1221 /* Read all the local symbols. */ |
1331 fn->local_decls = lto_input_tree (ib, data_in); | 1222 len = lto_input_sleb128 (ib); |
1223 if (len > 0) | |
1224 { | |
1225 int i; | |
1226 VEC_safe_grow (tree, gc, fn->local_decls, len); | |
1227 for (i = 0; i < len; i++) | |
1228 { | |
1229 tree t = lto_input_tree (ib, data_in); | |
1230 VEC_replace (tree, fn->local_decls, i, t); | |
1231 } | |
1232 } | |
1332 | 1233 |
1333 /* Read all function arguments. We need to re-map them here to the | 1234 /* Read all function arguments. We need to re-map them here to the |
1334 arguments of the merged function declaration. */ | 1235 arguments of the merged function declaration. */ |
1335 args = lto_input_tree (ib, data_in); | 1236 args = lto_input_tree (ib, data_in); |
1336 for (oarg = args, narg = DECL_ARGUMENTS (fn_decl); | 1237 for (oarg = args, narg = DECL_ARGUMENTS (fn_decl); |
1354 | 1255 |
1355 /* Read the tree of lexical scopes for the function. */ | 1256 /* Read the tree of lexical scopes for the function. */ |
1356 DECL_INITIAL (fn_decl) = lto_input_tree (ib, data_in); | 1257 DECL_INITIAL (fn_decl) = lto_input_tree (ib, data_in); |
1357 gcc_assert (DECL_INITIAL (fn_decl)); | 1258 gcc_assert (DECL_INITIAL (fn_decl)); |
1358 DECL_SAVED_TREE (fn_decl) = NULL_TREE; | 1259 DECL_SAVED_TREE (fn_decl) = NULL_TREE; |
1260 node = cgraph_node (fn_decl); | |
1359 | 1261 |
1360 /* Read all the basic blocks. */ | 1262 /* Read all the basic blocks. */ |
1361 tag = input_record_start (ib); | 1263 tag = input_record_start (ib); |
1362 while (tag) | 1264 while (tag) |
1363 { | 1265 { |
1364 input_bb (ib, tag, data_in, fn); | 1266 input_bb (ib, tag, data_in, fn, |
1267 node->count_materialization_scale); | |
1365 tag = input_record_start (ib); | 1268 tag = input_record_start (ib); |
1366 } | 1269 } |
1367 | 1270 |
1368 /* Fix up the call statements that are mentioned in the callgraph | 1271 /* Fix up the call statements that are mentioned in the callgraph |
1369 edges. */ | 1272 edges. */ |
1370 renumber_gimple_stmt_uids (); | 1273 renumber_gimple_stmt_uids (); |
1371 stmts = (gimple *) xcalloc (gimple_stmt_max_uid (fn), sizeof (gimple)); | 1274 stmts = (gimple *) xcalloc (gimple_stmt_max_uid (fn), sizeof (gimple)); |
1372 FOR_ALL_BB (bb) | 1275 FOR_ALL_BB (bb) |
1373 { | 1276 { |
1374 gimple_stmt_iterator bsi; | 1277 gimple_stmt_iterator bsi = gsi_start_bb (bb); |
1375 for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) | 1278 while (!gsi_end_p (bsi)) |
1376 { | 1279 { |
1377 gimple stmt = gsi_stmt (bsi); | 1280 gimple stmt = gsi_stmt (bsi); |
1378 stmts[gimple_uid (stmt)] = stmt; | 1281 /* If we're recompiling LTO objects with debug stmts but |
1282 we're not supposed to have debug stmts, remove them now. | |
1283 We can't remove them earlier because this would cause uid | |
1284 mismatches in fixups, but we can do it at this point, as | |
1285 long as debug stmts don't require fixups. */ | |
1286 if (!MAY_HAVE_DEBUG_STMTS && is_gimple_debug (stmt)) | |
1287 { | |
1288 gimple_stmt_iterator gsi = bsi; | |
1289 gsi_next (&bsi); | |
1290 gsi_remove (&gsi, true); | |
1291 } | |
1292 else | |
1293 { | |
1294 gsi_next (&bsi); | |
1295 stmts[gimple_uid (stmt)] = stmt; | |
1296 } | |
1379 } | 1297 } |
1380 } | 1298 } |
1381 | 1299 |
1382 /* Set the gimple body to the statement sequence in the entry | 1300 /* Set the gimple body to the statement sequence in the entry |
1383 basic block. FIXME lto, this is fairly hacky. The existence | 1301 basic block. FIXME lto, this is fairly hacky. The existence |
1386 { | 1304 { |
1387 edge_iterator ei = ei_start (ENTRY_BLOCK_PTR->succs); | 1305 edge_iterator ei = ei_start (ENTRY_BLOCK_PTR->succs); |
1388 gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest)); | 1306 gimple_set_body (fn_decl, bb_seq (ei_edge (ei)->dest)); |
1389 } | 1307 } |
1390 | 1308 |
1391 node = cgraph_node (fn_decl); | |
1392 fixup_call_stmt_edges (node, stmts); | 1309 fixup_call_stmt_edges (node, stmts); |
1393 execute_all_ipa_stmt_fixups (node, stmts); | 1310 execute_all_ipa_stmt_fixups (node, stmts); |
1394 | 1311 |
1395 update_ssa (TODO_update_ssa_only_virtuals); | 1312 update_ssa (TODO_update_ssa_only_virtuals); |
1396 free_dominance_info (CDI_DOMINATORS); | 1313 free_dominance_info (CDI_DOMINATORS); |
1479 | 1396 |
1480 if (section_type == LTO_section_function_body) | 1397 if (section_type == LTO_section_function_body) |
1481 { | 1398 { |
1482 struct function *fn = DECL_STRUCT_FUNCTION (fn_decl); | 1399 struct function *fn = DECL_STRUCT_FUNCTION (fn_decl); |
1483 struct lto_in_decl_state *decl_state; | 1400 struct lto_in_decl_state *decl_state; |
1401 struct cgraph_node *node = cgraph_node (fn_decl); | |
1484 | 1402 |
1485 push_cfun (fn); | 1403 push_cfun (fn); |
1486 init_tree_ssa (fn); | 1404 init_tree_ssa (fn); |
1487 | 1405 |
1488 /* Use the function's decl state. */ | 1406 /* Use the function's decl state. */ |
1489 decl_state = lto_get_function_in_decl_state (file_data, fn_decl); | 1407 decl_state = lto_get_function_in_decl_state (file_data, fn_decl); |
1490 gcc_assert (decl_state); | 1408 gcc_assert (decl_state); |
1491 file_data->current_decl_state = decl_state; | 1409 file_data->current_decl_state = decl_state; |
1492 | 1410 |
1493 input_cfg (&ib_cfg, fn); | 1411 input_cfg (&ib_cfg, fn, node->count_materialization_scale); |
1494 | 1412 |
1495 /* Set up the struct function. */ | 1413 /* Set up the struct function. */ |
1496 input_function (fn_decl, data_in, &ib_main); | 1414 input_function (fn_decl, data_in, &ib_main); |
1497 | 1415 |
1498 /* We should now be in SSA. */ | 1416 /* We should now be in SSA. */ |
1578 /* TREE_PUBLIC is used on types to indicate that the type | 1496 /* TREE_PUBLIC is used on types to indicate that the type |
1579 has a TYPE_CACHED_VALUES vector. This is not streamed out, | 1497 has a TYPE_CACHED_VALUES vector. This is not streamed out, |
1580 so we skip it here. */ | 1498 so we skip it here. */ |
1581 TREE_PUBLIC (expr) = (unsigned) bp_unpack_value (bp, 1); | 1499 TREE_PUBLIC (expr) = (unsigned) bp_unpack_value (bp, 1); |
1582 } | 1500 } |
1501 else | |
1502 bp_unpack_value (bp, 4); | |
1583 TREE_ADDRESSABLE (expr) = (unsigned) bp_unpack_value (bp, 1); | 1503 TREE_ADDRESSABLE (expr) = (unsigned) bp_unpack_value (bp, 1); |
1584 TREE_THIS_VOLATILE (expr) = (unsigned) bp_unpack_value (bp, 1); | 1504 TREE_THIS_VOLATILE (expr) = (unsigned) bp_unpack_value (bp, 1); |
1585 if (DECL_P (expr)) | 1505 if (DECL_P (expr)) |
1586 DECL_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1); | 1506 DECL_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1); |
1587 else if (TYPE_P (expr)) | 1507 else if (TYPE_P (expr)) |
1588 TYPE_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1); | 1508 TYPE_UNSIGNED (expr) = (unsigned) bp_unpack_value (bp, 1); |
1509 else | |
1510 bp_unpack_value (bp, 1); | |
1589 TREE_ASM_WRITTEN (expr) = (unsigned) bp_unpack_value (bp, 1); | 1511 TREE_ASM_WRITTEN (expr) = (unsigned) bp_unpack_value (bp, 1); |
1590 TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1); | 1512 TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1); |
1591 TREE_USED (expr) = (unsigned) bp_unpack_value (bp, 1); | 1513 TREE_USED (expr) = (unsigned) bp_unpack_value (bp, 1); |
1592 TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1); | 1514 TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1); |
1593 TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1); | 1515 TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1); |
1594 TREE_PRIVATE (expr) = (unsigned) bp_unpack_value (bp, 1); | 1516 TREE_PRIVATE (expr) = (unsigned) bp_unpack_value (bp, 1); |
1595 TREE_PROTECTED (expr) = (unsigned) bp_unpack_value (bp, 1); | 1517 TREE_PROTECTED (expr) = (unsigned) bp_unpack_value (bp, 1); |
1596 TREE_DEPRECATED (expr) = (unsigned) bp_unpack_value (bp, 1); | 1518 TREE_DEPRECATED (expr) = (unsigned) bp_unpack_value (bp, 1); |
1597 if (TYPE_P (expr)) | 1519 if (TYPE_P (expr)) |
1598 TYPE_SATURATING (expr) = (unsigned) bp_unpack_value (bp, 1); | 1520 TYPE_SATURATING (expr) = (unsigned) bp_unpack_value (bp, 1); |
1599 if (TREE_CODE (expr) == SSA_NAME) | 1521 else if (TREE_CODE (expr) == SSA_NAME) |
1600 SSA_NAME_IS_DEFAULT_DEF (expr) = (unsigned) bp_unpack_value (bp, 1); | 1522 SSA_NAME_IS_DEFAULT_DEF (expr) = (unsigned) bp_unpack_value (bp, 1); |
1523 else | |
1524 bp_unpack_value (bp, 1); | |
1601 } | 1525 } |
1602 | 1526 |
1603 | 1527 |
1604 /* Unpack all the non-pointer fields of the TS_REAL_CST structure of | 1528 /* Unpack all the non-pointer fields of the TS_REAL_CST structure of |
1605 expression EXPR from bitpack BP. */ | 1529 expression EXPR from bitpack BP. */ |
1618 r.canonical = (unsigned) bp_unpack_value (bp, 1); | 1542 r.canonical = (unsigned) bp_unpack_value (bp, 1); |
1619 r.uexp = (unsigned) bp_unpack_value (bp, EXP_BITS); | 1543 r.uexp = (unsigned) bp_unpack_value (bp, EXP_BITS); |
1620 for (i = 0; i < SIGSZ; i++) | 1544 for (i = 0; i < SIGSZ; i++) |
1621 r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG); | 1545 r.sig[i] = (unsigned long) bp_unpack_value (bp, HOST_BITS_PER_LONG); |
1622 | 1546 |
1623 rp = GGC_NEW (REAL_VALUE_TYPE); | 1547 rp = ggc_alloc_real_value (); |
1624 memcpy (rp, &r, sizeof (REAL_VALUE_TYPE)); | 1548 memcpy (rp, &r, sizeof (REAL_VALUE_TYPE)); |
1625 TREE_REAL_CST_PTR (expr) = rp; | 1549 TREE_REAL_CST_PTR (expr) = rp; |
1626 } | 1550 } |
1627 | 1551 |
1628 | 1552 |
1634 { | 1558 { |
1635 struct fixed_value fv; | 1559 struct fixed_value fv; |
1636 | 1560 |
1637 fv.data.low = (HOST_WIDE_INT) bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT); | 1561 fv.data.low = (HOST_WIDE_INT) bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT); |
1638 fv.data.high = (HOST_WIDE_INT) bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT); | 1562 fv.data.high = (HOST_WIDE_INT) bp_unpack_value (bp, HOST_BITS_PER_WIDE_INT); |
1563 fv.mode = (enum machine_mode) bp_unpack_value (bp, HOST_BITS_PER_INT); | |
1639 TREE_FIXED_CST (expr) = fv; | 1564 TREE_FIXED_CST (expr) = fv; |
1640 } | 1565 } |
1641 | 1566 |
1642 | 1567 |
1643 /* Unpack all the non-pointer fields of the TS_DECL_COMMON structure | 1568 /* Unpack all the non-pointer fields of the TS_DECL_COMMON structure |
1756 = (unsigned) bp_unpack_value (bp, 1); | 1681 = (unsigned) bp_unpack_value (bp, 1); |
1757 DECL_NO_LIMIT_STACK (expr) = (unsigned) bp_unpack_value (bp, 1); | 1682 DECL_NO_LIMIT_STACK (expr) = (unsigned) bp_unpack_value (bp, 1); |
1758 DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1); | 1683 DECL_DISREGARD_INLINE_LIMITS (expr) = (unsigned) bp_unpack_value (bp, 1); |
1759 DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1); | 1684 DECL_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1); |
1760 DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1); | 1685 DECL_LOOPING_CONST_OR_PURE_P (expr) = (unsigned) bp_unpack_value (bp, 1); |
1686 if (DECL_STATIC_DESTRUCTOR (expr)) | |
1687 { | |
1688 priority_type p = (priority_type) bp_unpack_value (bp, HOST_BITS_PER_SHORT); | |
1689 SET_DECL_FINI_PRIORITY (expr, p); | |
1690 } | |
1761 } | 1691 } |
1762 | 1692 |
1763 | 1693 |
1764 /* Unpack all the non-pointer fields of the TS_TYPE structure | 1694 /* Unpack all the non-pointer fields of the TS_TYPE structure |
1765 of expression EXPR from bitpack BP. */ | 1695 of expression EXPR from bitpack BP. */ |
1767 static void | 1697 static void |
1768 unpack_ts_type_value_fields (struct bitpack_d *bp, tree expr) | 1698 unpack_ts_type_value_fields (struct bitpack_d *bp, tree expr) |
1769 { | 1699 { |
1770 enum machine_mode mode; | 1700 enum machine_mode mode; |
1771 | 1701 |
1772 TYPE_PRECISION (expr) = (unsigned) bp_unpack_value (bp, 9); | 1702 TYPE_PRECISION (expr) = (unsigned) bp_unpack_value (bp, 10); |
1773 mode = (enum machine_mode) bp_unpack_value (bp, 7); | 1703 mode = (enum machine_mode) bp_unpack_value (bp, 8); |
1774 SET_TYPE_MODE (expr, mode); | 1704 SET_TYPE_MODE (expr, mode); |
1775 TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1); | 1705 TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1); |
1776 TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1); | 1706 TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1); |
1777 TYPE_NEEDS_CONSTRUCTING (expr) = (unsigned) bp_unpack_value (bp, 1); | 1707 TYPE_NEEDS_CONSTRUCTING (expr) = (unsigned) bp_unpack_value (bp, 1); |
1778 if (RECORD_OR_UNION_TYPE_P (expr)) | 1708 if (RECORD_OR_UNION_TYPE_P (expr)) |
1796 { | 1726 { |
1797 BLOCK_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1); | 1727 BLOCK_ABSTRACT (expr) = (unsigned) bp_unpack_value (bp, 1); |
1798 BLOCK_NUMBER (expr) = (unsigned) bp_unpack_value (bp, 31); | 1728 BLOCK_NUMBER (expr) = (unsigned) bp_unpack_value (bp, 31); |
1799 } | 1729 } |
1800 | 1730 |
1731 /* Unpack all the non-pointer fields of the TS_TRANSLATION_UNIT_DECL | |
1732 structure of expression EXPR from bitpack BP. */ | |
1733 | |
1734 static void | |
1735 unpack_ts_translation_unit_decl_value_fields (struct bitpack_d *bp ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED) | |
1736 { | |
1737 } | |
1801 | 1738 |
1802 /* Unpack all the non-pointer fields in EXPR into a bit pack. */ | 1739 /* Unpack all the non-pointer fields in EXPR into a bit pack. */ |
1803 | 1740 |
1804 static void | 1741 static void |
1805 unpack_value_fields (struct bitpack_d *bp, tree expr) | 1742 unpack_value_fields (struct bitpack_d *bp, tree expr) |
1851 if (CODE_CONTAINS_STRUCT (code, TS_OMP_CLAUSE)) | 1788 if (CODE_CONTAINS_STRUCT (code, TS_OMP_CLAUSE)) |
1852 { | 1789 { |
1853 /* This is only used by High GIMPLE. */ | 1790 /* This is only used by High GIMPLE. */ |
1854 gcc_unreachable (); | 1791 gcc_unreachable (); |
1855 } | 1792 } |
1856 } | 1793 |
1857 | 1794 if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL)) |
1858 | 1795 unpack_ts_translation_unit_decl_value_fields (bp, expr); |
1859 /* Read a bitpack from input block IB. */ | |
1860 | |
1861 struct bitpack_d * | |
1862 lto_input_bitpack (struct lto_input_block *ib) | |
1863 { | |
1864 unsigned i, num_words; | |
1865 struct bitpack_d *bp; | |
1866 | |
1867 bp = bitpack_create (); | |
1868 | |
1869 /* If we are about to read more than a handful of words, something | |
1870 is wrong. This check is overly strict, but it acts as an early | |
1871 warning. No streamed object has hundreds of bits in its fields. */ | |
1872 num_words = lto_input_uleb128 (ib); | |
1873 gcc_assert (num_words < 20); | |
1874 | |
1875 for (i = 0; i < num_words; i++) | |
1876 { | |
1877 bitpack_word_t w = lto_input_uleb128 (ib); | |
1878 VEC_safe_push (bitpack_word_t, heap, bp->values, w); | |
1879 } | |
1880 | |
1881 return bp; | |
1882 } | 1796 } |
1883 | 1797 |
1884 | 1798 |
1885 /* Materialize a new tree from input block IB using descriptors in | 1799 /* Materialize a new tree from input block IB using descriptors in |
1886 DATA_IN. The code for the new tree should match TAG. Store in | 1800 DATA_IN. The code for the new tree should match TAG. Store in |
1888 | 1802 |
1889 static tree | 1803 static tree |
1890 lto_materialize_tree (struct lto_input_block *ib, struct data_in *data_in, | 1804 lto_materialize_tree (struct lto_input_block *ib, struct data_in *data_in, |
1891 enum LTO_tags tag, int *ix_p) | 1805 enum LTO_tags tag, int *ix_p) |
1892 { | 1806 { |
1893 struct bitpack_d *bp; | 1807 struct bitpack_d bp; |
1894 enum tree_code code; | 1808 enum tree_code code; |
1895 tree result; | 1809 tree result; |
1896 #ifdef LTO_STREAMER_DEBUG | 1810 #ifdef LTO_STREAMER_DEBUG |
1897 HOST_WIDEST_INT orig_address_in_writer; | 1811 HOST_WIDEST_INT orig_address_in_writer; |
1898 #endif | 1812 #endif |
1953 /* Read the bitpack of non-pointer values from IB. */ | 1867 /* Read the bitpack of non-pointer values from IB. */ |
1954 bp = lto_input_bitpack (ib); | 1868 bp = lto_input_bitpack (ib); |
1955 | 1869 |
1956 /* The first word in BP contains the code of the tree that we | 1870 /* The first word in BP contains the code of the tree that we |
1957 are about to read. */ | 1871 are about to read. */ |
1958 code = (enum tree_code) bp_unpack_value (bp, 16); | 1872 code = (enum tree_code) bp_unpack_value (&bp, 16); |
1959 lto_tag_check (lto_tree_code_to_tag (code), tag); | 1873 lto_tag_check (lto_tree_code_to_tag (code), tag); |
1960 | 1874 |
1961 /* Unpack all the value fields from BP. */ | 1875 /* Unpack all the value fields from BP. */ |
1962 unpack_value_fields (bp, result); | 1876 unpack_value_fields (&bp, result); |
1963 bitpack_delete (bp); | |
1964 | 1877 |
1965 /* Enter RESULT in the reader cache. This will make RESULT | 1878 /* Enter RESULT in the reader cache. This will make RESULT |
1966 available so that circular references in the rest of the tree | 1879 available so that circular references in the rest of the tree |
1967 structure can be resolved in subsequent calls to lto_input_tree. */ | 1880 structure can be resolved in subsequent calls to lto_input_tree. */ |
1968 lto_streamer_cache_insert_at (data_in->reader_cache, result, ix); | 1881 lto_streamer_cache_insert_at (data_in->reader_cache, result, ix); |
2005 | 1918 |
2006 static void | 1919 static void |
2007 lto_input_ts_common_tree_pointers (struct lto_input_block *ib, | 1920 lto_input_ts_common_tree_pointers (struct lto_input_block *ib, |
2008 struct data_in *data_in, tree expr) | 1921 struct data_in *data_in, tree expr) |
2009 { | 1922 { |
2010 TREE_TYPE (expr) = lto_input_tree (ib, data_in); | 1923 if (TREE_CODE (expr) != IDENTIFIER_NODE) |
1924 TREE_TYPE (expr) = lto_input_tree (ib, data_in); | |
2011 } | 1925 } |
2012 | 1926 |
2013 | 1927 |
2014 /* Read all pointer fields in the TS_VECTOR structure of EXPR from input | 1928 /* Read all pointer fields in the TS_VECTOR structure of EXPR from input |
2015 block IB. DATA_IN contains tables and descriptors for the | 1929 block IB. DATA_IN contains tables and descriptors for the |
2059 struct data_in *data_in, tree expr) | 1973 struct data_in *data_in, tree expr) |
2060 { | 1974 { |
2061 DECL_SIZE (expr) = lto_input_tree (ib, data_in); | 1975 DECL_SIZE (expr) = lto_input_tree (ib, data_in); |
2062 DECL_SIZE_UNIT (expr) = lto_input_tree (ib, data_in); | 1976 DECL_SIZE_UNIT (expr) = lto_input_tree (ib, data_in); |
2063 | 1977 |
2064 if (TREE_CODE (expr) != FUNCTION_DECL) | 1978 if (TREE_CODE (expr) != FUNCTION_DECL |
1979 && TREE_CODE (expr) != TRANSLATION_UNIT_DECL) | |
2065 DECL_INITIAL (expr) = lto_input_tree (ib, data_in); | 1980 DECL_INITIAL (expr) = lto_input_tree (ib, data_in); |
2066 | 1981 |
2067 DECL_ATTRIBUTES (expr) = lto_input_tree (ib, data_in); | 1982 DECL_ATTRIBUTES (expr) = lto_input_tree (ib, data_in); |
2068 DECL_ABSTRACT_ORIGIN (expr) = lto_input_tree (ib, data_in); | 1983 /* Do not stream DECL_ABSTRACT_ORIGIN. We cannot handle debug information |
1984 for early inlining so drop it on the floor instead of ICEing in | |
1985 dwarf2out.c. */ | |
2069 | 1986 |
2070 if (TREE_CODE (expr) == PARM_DECL) | 1987 if (TREE_CODE (expr) == PARM_DECL) |
2071 TREE_CHAIN (expr) = lto_input_chain (ib, data_in); | 1988 TREE_CHAIN (expr) = lto_input_chain (ib, data_in); |
2072 | 1989 |
2073 if ((TREE_CODE (expr) == VAR_DECL | 1990 if ((TREE_CODE (expr) == VAR_DECL |
2074 || TREE_CODE (expr) == PARM_DECL) | 1991 || TREE_CODE (expr) == PARM_DECL) |
2075 && DECL_HAS_VALUE_EXPR_P (expr)) | 1992 && DECL_HAS_VALUE_EXPR_P (expr)) |
2076 SET_DECL_VALUE_EXPR (expr, lto_input_tree (ib, data_in)); | 1993 SET_DECL_VALUE_EXPR (expr, lto_input_tree (ib, data_in)); |
1994 | |
1995 if (TREE_CODE (expr) == VAR_DECL) | |
1996 { | |
1997 tree dexpr = lto_input_tree (ib, data_in); | |
1998 if (dexpr) | |
1999 SET_DECL_DEBUG_EXPR (expr, dexpr); | |
2000 } | |
2077 } | 2001 } |
2078 | 2002 |
2079 | 2003 |
2080 /* Read all pointer fields in the TS_DECL_NON_COMMON structure of | 2004 /* Read all pointer fields in the TS_DECL_NON_COMMON structure of |
2081 EXPR from input block IB. DATA_IN contains tables and descriptors for the | 2005 EXPR from input block IB. DATA_IN contains tables and descriptors for the |
2170 else if (RECORD_OR_UNION_TYPE_P (expr)) | 2094 else if (RECORD_OR_UNION_TYPE_P (expr)) |
2171 TYPE_FIELDS (expr) = lto_input_tree (ib, data_in); | 2095 TYPE_FIELDS (expr) = lto_input_tree (ib, data_in); |
2172 else if (TREE_CODE (expr) == FUNCTION_TYPE | 2096 else if (TREE_CODE (expr) == FUNCTION_TYPE |
2173 || TREE_CODE (expr) == METHOD_TYPE) | 2097 || TREE_CODE (expr) == METHOD_TYPE) |
2174 TYPE_ARG_TYPES (expr) = lto_input_tree (ib, data_in); | 2098 TYPE_ARG_TYPES (expr) = lto_input_tree (ib, data_in); |
2175 else if (TREE_CODE (expr) == VECTOR_TYPE) | |
2176 TYPE_DEBUG_REPRESENTATION_TYPE (expr) = lto_input_tree (ib, data_in); | |
2177 | 2099 |
2178 TYPE_SIZE (expr) = lto_input_tree (ib, data_in); | 2100 TYPE_SIZE (expr) = lto_input_tree (ib, data_in); |
2179 TYPE_SIZE_UNIT (expr) = lto_input_tree (ib, data_in); | 2101 TYPE_SIZE_UNIT (expr) = lto_input_tree (ib, data_in); |
2180 TYPE_ATTRIBUTES (expr) = lto_input_tree (ib, data_in); | 2102 TYPE_ATTRIBUTES (expr) = lto_input_tree (ib, data_in); |
2181 TYPE_NAME (expr) = lto_input_tree (ib, data_in); | 2103 TYPE_NAME (expr) = lto_input_tree (ib, data_in); |
2188 /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists | 2110 /* Do not stream TYPE_NEXT_VARIANT, we reconstruct the variant lists |
2189 during fixup. */ | 2111 during fixup. */ |
2190 if (RECORD_OR_UNION_TYPE_P (expr)) | 2112 if (RECORD_OR_UNION_TYPE_P (expr)) |
2191 TYPE_BINFO (expr) = lto_input_tree (ib, data_in); | 2113 TYPE_BINFO (expr) = lto_input_tree (ib, data_in); |
2192 TYPE_CONTEXT (expr) = lto_input_tree (ib, data_in); | 2114 TYPE_CONTEXT (expr) = lto_input_tree (ib, data_in); |
2193 TYPE_CANONICAL (expr) = lto_input_tree (ib, data_in); | 2115 /* TYPE_CANONICAL gets re-computed during type merging. */ |
2116 TYPE_CANONICAL (expr) = NULL_TREE; | |
2194 TYPE_STUB_DECL (expr) = lto_input_tree (ib, data_in); | 2117 TYPE_STUB_DECL (expr) = lto_input_tree (ib, data_in); |
2195 } | 2118 } |
2196 | 2119 |
2197 | 2120 |
2198 /* Read all pointer fields in the TS_LIST structure of EXPR from input | 2121 /* Read all pointer fields in the TS_LIST structure of EXPR from input |
2256 | 2179 |
2257 static void | 2180 static void |
2258 lto_input_ts_block_tree_pointers (struct lto_input_block *ib, | 2181 lto_input_ts_block_tree_pointers (struct lto_input_block *ib, |
2259 struct data_in *data_in, tree expr) | 2182 struct data_in *data_in, tree expr) |
2260 { | 2183 { |
2261 unsigned i, len; | 2184 /* Do not stream BLOCK_SOURCE_LOCATION. We cannot handle debug information |
2262 | 2185 for early inlining so drop it on the floor instead of ICEing in |
2263 BLOCK_SOURCE_LOCATION (expr) = lto_input_location (ib, data_in); | 2186 dwarf2out.c. */ |
2264 BLOCK_VARS (expr) = lto_input_chain (ib, data_in); | 2187 BLOCK_VARS (expr) = lto_input_chain (ib, data_in); |
2265 | 2188 |
2266 len = lto_input_uleb128 (ib); | 2189 /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information |
2267 for (i = 0; i < len; i++) | 2190 for early inlining so drop it on the floor instead of ICEing in |
2268 { | 2191 dwarf2out.c. */ |
2269 tree t = lto_input_tree (ib, data_in); | |
2270 VEC_safe_push (tree, gc, BLOCK_NONLOCALIZED_VARS (expr), t); | |
2271 } | |
2272 | 2192 |
2273 BLOCK_SUPERCONTEXT (expr) = lto_input_tree (ib, data_in); | 2193 BLOCK_SUPERCONTEXT (expr) = lto_input_tree (ib, data_in); |
2274 BLOCK_ABSTRACT_ORIGIN (expr) = lto_input_tree (ib, data_in); | 2194 /* Do not stream BLOCK_ABSTRACT_ORIGIN. We cannot handle debug information |
2195 for early inlining so drop it on the floor instead of ICEing in | |
2196 dwarf2out.c. */ | |
2275 BLOCK_FRAGMENT_ORIGIN (expr) = lto_input_tree (ib, data_in); | 2197 BLOCK_FRAGMENT_ORIGIN (expr) = lto_input_tree (ib, data_in); |
2276 BLOCK_FRAGMENT_CHAIN (expr) = lto_input_tree (ib, data_in); | 2198 BLOCK_FRAGMENT_CHAIN (expr) = lto_input_tree (ib, data_in); |
2277 BLOCK_SUBBLOCKS (expr) = lto_input_chain (ib, data_in); | 2199 /* We re-compute BLOCK_SUBBLOCKS of our parent here instead |
2200 of streaming it. For non-BLOCK BLOCK_SUPERCONTEXTs we still | |
2201 stream the child relationship explicitly. */ | |
2202 if (BLOCK_SUPERCONTEXT (expr) | |
2203 && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == BLOCK) | |
2204 { | |
2205 BLOCK_CHAIN (expr) = BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr)); | |
2206 BLOCK_SUBBLOCKS (BLOCK_SUPERCONTEXT (expr)) = expr; | |
2207 } | |
2208 /* The global block is rooted at the TU decl. Hook it here to | |
2209 avoid the need to stream in this block during WPA time. */ | |
2210 else if (BLOCK_SUPERCONTEXT (expr) | |
2211 && TREE_CODE (BLOCK_SUPERCONTEXT (expr)) == TRANSLATION_UNIT_DECL) | |
2212 DECL_INITIAL (BLOCK_SUPERCONTEXT (expr)) = expr; | |
2213 /* The function-level block is connected at the time we read in | |
2214 function bodies for the same reason. */ | |
2278 } | 2215 } |
2279 | 2216 |
2280 | 2217 |
2281 /* Read all pointer fields in the TS_BINFO structure of EXPR from input | 2218 /* Read all pointer fields in the TS_BINFO structure of EXPR from input |
2282 block IB. DATA_IN contains tables and descriptors for the | 2219 block IB. DATA_IN contains tables and descriptors for the |
2306 BINFO_VTABLE (expr) = lto_input_tree (ib, data_in); | 2243 BINFO_VTABLE (expr) = lto_input_tree (ib, data_in); |
2307 BINFO_VIRTUALS (expr) = lto_input_tree (ib, data_in); | 2244 BINFO_VIRTUALS (expr) = lto_input_tree (ib, data_in); |
2308 BINFO_VPTR_FIELD (expr) = lto_input_tree (ib, data_in); | 2245 BINFO_VPTR_FIELD (expr) = lto_input_tree (ib, data_in); |
2309 | 2246 |
2310 len = lto_input_uleb128 (ib); | 2247 len = lto_input_uleb128 (ib); |
2311 for (i = 0; i < len; i++) | 2248 if (len > 0) |
2312 { | 2249 { |
2313 tree a = lto_input_tree (ib, data_in); | 2250 VEC_reserve_exact (tree, gc, BINFO_BASE_ACCESSES (expr), len); |
2314 VEC_safe_push (tree, gc, BINFO_BASE_ACCESSES (expr), a); | 2251 for (i = 0; i < len; i++) |
2252 { | |
2253 tree a = lto_input_tree (ib, data_in); | |
2254 VEC_quick_push (tree, BINFO_BASE_ACCESSES (expr), a); | |
2255 } | |
2315 } | 2256 } |
2316 | 2257 |
2317 BINFO_INHERITANCE_CHAIN (expr) = lto_input_tree (ib, data_in); | 2258 BINFO_INHERITANCE_CHAIN (expr) = lto_input_tree (ib, data_in); |
2318 BINFO_SUBVTT_INDEX (expr) = lto_input_tree (ib, data_in); | 2259 BINFO_SUBVTT_INDEX (expr) = lto_input_tree (ib, data_in); |
2319 BINFO_VPTR_INDEX (expr) = lto_input_tree (ib, data_in); | 2260 BINFO_VPTR_INDEX (expr) = lto_input_tree (ib, data_in); |
2340 CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (expr), index, value); | 2281 CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (expr), index, value); |
2341 } | 2282 } |
2342 } | 2283 } |
2343 | 2284 |
2344 | 2285 |
2286 /* Input a TS_TARGET_OPTION tree from IB into EXPR. */ | |
2287 | |
2288 static void | |
2289 lto_input_ts_target_option (struct lto_input_block *ib, tree expr) | |
2290 { | |
2291 unsigned i, len; | |
2292 struct bitpack_d bp; | |
2293 struct cl_target_option *t = TREE_TARGET_OPTION (expr); | |
2294 | |
2295 bp = lto_input_bitpack (ib); | |
2296 len = sizeof (struct cl_target_option); | |
2297 for (i = 0; i < len; i++) | |
2298 ((unsigned char *)t)[i] = bp_unpack_value (&bp, 8); | |
2299 if (bp_unpack_value (&bp, 32) != 0x12345678) | |
2300 fatal_error ("cl_target_option size mismatch in LTO reader and writer"); | |
2301 } | |
2302 | |
2303 /* Input a TS_TRANSLATION_UNIT_DECL tree from IB and DATA_IN into EXPR. */ | |
2304 | |
2305 static void | |
2306 lto_input_ts_translation_unit_decl_tree_pointers (struct lto_input_block *ib, | |
2307 struct data_in *data_in, | |
2308 tree expr) | |
2309 { | |
2310 TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib)); | |
2311 VEC_safe_push (tree, gc, all_translation_units, expr); | |
2312 } | |
2313 | |
2345 /* Helper for lto_input_tree. Read all pointer fields in EXPR from | 2314 /* Helper for lto_input_tree. Read all pointer fields in EXPR from |
2346 input block IB. DATA_IN contains tables and descriptors for the | 2315 input block IB. DATA_IN contains tables and descriptors for the |
2347 file being read. */ | 2316 file being read. */ |
2348 | 2317 |
2349 static void | 2318 static void |
2424 { | 2393 { |
2425 sorry ("optimization options not supported yet"); | 2394 sorry ("optimization options not supported yet"); |
2426 } | 2395 } |
2427 | 2396 |
2428 if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) | 2397 if (CODE_CONTAINS_STRUCT (code, TS_TARGET_OPTION)) |
2429 { | 2398 lto_input_ts_target_option (ib, expr); |
2430 sorry ("target optimization options not supported yet"); | 2399 |
2431 } | 2400 if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL)) |
2401 lto_input_ts_translation_unit_decl_tree_pointers (ib, data_in, expr); | |
2432 } | 2402 } |
2433 | 2403 |
2434 | 2404 |
2435 /* Register DECL with the global symbol table and change its | 2405 /* Register DECL with the global symbol table and change its |
2436 name if necessary to avoid name clashes for static globals across | 2406 name if necessary to avoid name clashes for static globals across |
2437 different files. */ | 2407 different files. */ |
2438 | 2408 |
2439 static void | 2409 static void |
2440 lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl) | 2410 lto_register_var_decl_in_symtab (struct data_in *data_in, tree decl) |
2441 { | 2411 { |
2442 /* Register symbols with file or global scope to mark what input | 2412 tree context; |
2443 file has their definition. */ | 2413 |
2444 if (decl_function_context (decl) == NULL_TREE) | 2414 /* Variable has file scope, not local. Need to ensure static variables |
2445 { | 2415 between different files don't clash unexpectedly. */ |
2446 /* Variable has file scope, not local. Need to ensure static variables | 2416 if (!TREE_PUBLIC (decl) |
2447 between different files don't clash unexpectedly. */ | 2417 && !((context = decl_function_context (decl)) |
2448 if (!TREE_PUBLIC (decl)) | 2418 && auto_var_in_fn_p (decl, context))) |
2449 { | 2419 { |
2450 /* ??? We normally pre-mangle names before we serialize them | 2420 /* ??? We normally pre-mangle names before we serialize them |
2451 out. Here, in lto1, we do not know the language, and | 2421 out. Here, in lto1, we do not know the language, and |
2452 thus cannot do the mangling again. Instead, we just | 2422 thus cannot do the mangling again. Instead, we just |
2453 append a suffix to the mangled name. The resulting name, | 2423 append a suffix to the mangled name. The resulting name, |
2454 however, is not a properly-formed mangled name, and will | 2424 however, is not a properly-formed mangled name, and will |
2455 confuse any attempt to unmangle it. */ | 2425 confuse any attempt to unmangle it. */ |
2456 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | 2426 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); |
2457 char *label; | 2427 char *label; |
2458 | 2428 |
2459 ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); | 2429 ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); |
2460 SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label)); | 2430 SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label)); |
2461 rest_of_decl_compilation (decl, 1, 0); | 2431 rest_of_decl_compilation (decl, 1, 0); |
2462 } | 2432 |
2433 VEC_safe_push (tree, gc, lto_global_var_decls, decl); | |
2463 } | 2434 } |
2464 | 2435 |
2465 /* If this variable has already been declared, queue the | 2436 /* If this variable has already been declared, queue the |
2466 declaration for merging. */ | 2437 declaration for merging. */ |
2467 if (TREE_PUBLIC (decl)) | 2438 if (TREE_PUBLIC (decl)) |