Mercurial > hg > CbC > CbC_gcc
comparison gcc/lto-streamer-in.c @ 63:b7f97abdc517 gcc-4.6-20100522
update gcc from gcc-4.5.0 to gcc-4.6
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 24 May 2010 12:47:05 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
56:3c8a44c06a95 | 63:b7f97abdc517 |
---|---|
1 /* Read the GIMPLE representation from a file stream. | 1 /* Read the GIMPLE representation from a file stream. |
2 | 2 |
3 Copyright 2009 Free Software Foundation, Inc. | 3 Copyright 2009, 2010 Free Software Foundation, Inc. |
4 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> | 4 Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> |
5 Re-implemented by Diego Novillo <dnovillo@google.com> | 5 Re-implemented by Diego Novillo <dnovillo@google.com> |
6 | 6 |
7 This file is part of GCC. | 7 This file is part of GCC. |
8 | 8 |
28 #include "tree.h" | 28 #include "tree.h" |
29 #include "expr.h" | 29 #include "expr.h" |
30 #include "flags.h" | 30 #include "flags.h" |
31 #include "params.h" | 31 #include "params.h" |
32 #include "input.h" | 32 #include "input.h" |
33 #include "varray.h" | |
34 #include "hashtab.h" | 33 #include "hashtab.h" |
35 #include "basic-block.h" | 34 #include "basic-block.h" |
36 #include "tree-flow.h" | 35 #include "tree-flow.h" |
37 #include "tree-pass.h" | 36 #include "tree-pass.h" |
38 #include "cgraph.h" | 37 #include "cgraph.h" |
356 case LTO_const_decl_ref: | 355 case LTO_const_decl_ref: |
357 case LTO_imported_decl_ref: | 356 case LTO_imported_decl_ref: |
358 case LTO_label_decl_ref: | 357 case LTO_label_decl_ref: |
359 ix_u = lto_input_uleb128 (ib); | 358 ix_u = lto_input_uleb128 (ib); |
360 result = lto_file_decl_data_get_var_decl (data_in->file_data, ix_u); | 359 result = lto_file_decl_data_get_var_decl (data_in->file_data, ix_u); |
361 if (TREE_CODE (result) == VAR_DECL) | |
362 varpool_mark_needed_node (varpool_node (result)); | |
363 break; | 360 break; |
364 | 361 |
365 default: | 362 default: |
366 gcc_unreachable (); | 363 gcc_unreachable (); |
367 } | 364 } |
944 TREE_OPERAND (op, 0) = build1 (VIEW_CONVERT_EXPR, wanted_type, | 941 TREE_OPERAND (op, 0) = build1 (VIEW_CONVERT_EXPR, wanted_type, |
945 TREE_OPERAND (op, 0)); | 942 TREE_OPERAND (op, 0)); |
946 } | 943 } |
947 | 944 |
948 /* Fixup reference tree operands for substituted prevailing decls | 945 /* Fixup reference tree operands for substituted prevailing decls |
949 with mismatched types in STMT. */ | 946 with mismatched types in STMT. This handles plain DECLs where |
947 we need the stmt for context to lookup the required type. */ | |
950 | 948 |
951 static void | 949 static void |
952 maybe_fixup_decls (gimple stmt) | 950 maybe_fixup_decls (gimple stmt) |
953 { | 951 { |
954 /* We have to fixup replaced decls here in case there were | 952 /* We have to fixup replaced decls here in case there were |
965 { | 963 { |
966 if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) | 964 if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) |
967 gimple_assign_set_rhs1 (stmt, build1 (VIEW_CONVERT_EXPR, | 965 gimple_assign_set_rhs1 (stmt, build1 (VIEW_CONVERT_EXPR, |
968 TREE_TYPE (lhs), rhs)); | 966 TREE_TYPE (lhs), rhs)); |
969 } | 967 } |
970 else if (handled_component_p (rhs)) | |
971 maybe_fixup_handled_component (rhs); | |
972 /* Then catch scalar stores. */ | 968 /* Then catch scalar stores. */ |
973 else if (TREE_CODE (lhs) == VAR_DECL) | 969 else if (TREE_CODE (lhs) == VAR_DECL) |
974 { | 970 { |
975 if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) | 971 if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) |
976 gimple_assign_set_lhs (stmt, build1 (VIEW_CONVERT_EXPR, | 972 gimple_assign_set_lhs (stmt, build1 (VIEW_CONVERT_EXPR, |
977 TREE_TYPE (rhs), lhs)); | 973 TREE_TYPE (rhs), lhs)); |
978 } | 974 } |
979 else if (handled_component_p (lhs)) | |
980 maybe_fixup_handled_component (lhs); | |
981 } | 975 } |
982 else if (is_gimple_call (stmt)) | 976 else if (is_gimple_call (stmt)) |
983 { | 977 { |
984 tree lhs = gimple_call_lhs (stmt); | 978 tree lhs = gimple_call_lhs (stmt); |
985 | 979 |
989 gimple_call_return_type (stmt))) | 983 gimple_call_return_type (stmt))) |
990 gimple_call_set_lhs (stmt, build1 (VIEW_CONVERT_EXPR, | 984 gimple_call_set_lhs (stmt, build1 (VIEW_CONVERT_EXPR, |
991 gimple_call_return_type (stmt), | 985 gimple_call_return_type (stmt), |
992 lhs)); | 986 lhs)); |
993 } | 987 } |
994 else if (lhs && handled_component_p (lhs)) | |
995 maybe_fixup_handled_component (lhs); | |
996 | 988 |
997 /* Arguments, especially for varargs functions will be funny... */ | 989 /* Arguments, especially for varargs functions will be funny... */ |
998 } | 990 } |
999 } | 991 } |
1000 | 992 |
1050 /* FIXME lto. Move most of this into a new gimple_asm_set_string(). */ | 1042 /* FIXME lto. Move most of this into a new gimple_asm_set_string(). */ |
1051 tree str; | 1043 tree str; |
1052 stmt->gimple_asm.ni = lto_input_uleb128 (ib); | 1044 stmt->gimple_asm.ni = lto_input_uleb128 (ib); |
1053 stmt->gimple_asm.no = lto_input_uleb128 (ib); | 1045 stmt->gimple_asm.no = lto_input_uleb128 (ib); |
1054 stmt->gimple_asm.nc = lto_input_uleb128 (ib); | 1046 stmt->gimple_asm.nc = lto_input_uleb128 (ib); |
1047 stmt->gimple_asm.nl = lto_input_uleb128 (ib); | |
1055 str = input_string_cst (data_in, ib); | 1048 str = input_string_cst (data_in, ib); |
1056 stmt->gimple_asm.string = TREE_STRING_POINTER (str); | 1049 stmt->gimple_asm.string = TREE_STRING_POINTER (str); |
1057 } | 1050 } |
1058 /* Fallthru */ | 1051 /* Fallthru */ |
1059 | 1052 |
1067 case GIMPLE_DEBUG: | 1060 case GIMPLE_DEBUG: |
1068 for (i = 0; i < num_ops; i++) | 1061 for (i = 0; i < num_ops; i++) |
1069 { | 1062 { |
1070 tree op = lto_input_tree (ib, data_in); | 1063 tree op = lto_input_tree (ib, data_in); |
1071 gimple_set_op (stmt, i, op); | 1064 gimple_set_op (stmt, i, op); |
1072 | 1065 if (!op) |
1073 /* Fixup FIELD_DECLs. */ | 1066 continue; |
1074 while (op && handled_component_p (op)) | 1067 |
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 | |
1084 by decl merging. */ | |
1085 if (TREE_CODE (op) == ADDR_EXPR) | |
1086 op = TREE_OPERAND (op, 0); | |
1087 while (handled_component_p (op)) | |
1075 { | 1088 { |
1076 if (TREE_CODE (op) == COMPONENT_REF) | 1089 if (TREE_CODE (op) == COMPONENT_REF) |
1077 { | 1090 { |
1078 tree field, type, tem; | 1091 tree field, type, tem; |
1079 field = TREE_OPERAND (op, 1); | 1092 field = TREE_OPERAND (op, 1); |
1080 type = DECL_CONTEXT (field); | 1093 type = DECL_CONTEXT (field); |
1081 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) | 1094 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) |
1082 { | 1095 { |
1083 if (tem == field | 1096 if (tem == field |
1084 || (TREE_TYPE (tem) == TREE_TYPE (field) | 1097 || (TREE_TYPE (tem) == TREE_TYPE (field) |
1085 && compare_field_offset (tem, field))) | 1098 && DECL_NONADDRESSABLE_P (tem) |
1099 == DECL_NONADDRESSABLE_P (field) | |
1100 && gimple_compare_field_offset (tem, field))) | |
1086 break; | 1101 break; |
1087 } | 1102 } |
1088 /* In case of type mismatches across units we can fail | 1103 /* In case of type mismatches across units we can fail |
1089 to unify some types and thus not find a proper | 1104 to unify some types and thus not find a proper |
1090 field-decl here. So only assert here if checking | 1105 field-decl here. So only assert here if checking |
1094 #endif | 1109 #endif |
1095 if (tem != NULL_TREE) | 1110 if (tem != NULL_TREE) |
1096 TREE_OPERAND (op, 1) = tem; | 1111 TREE_OPERAND (op, 1) = tem; |
1097 } | 1112 } |
1098 | 1113 |
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; | |
1099 op = TREE_OPERAND (op, 0); | 1118 op = TREE_OPERAND (op, 0); |
1100 } | 1119 } |
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); | |
1101 } | 1125 } |
1102 break; | 1126 break; |
1103 | 1127 |
1104 case GIMPLE_NOP: | 1128 case GIMPLE_NOP: |
1105 case GIMPLE_PREDICT: | 1129 case GIMPLE_PREDICT: |
1131 if (TREE_CODE (op) == SSA_NAME) | 1155 if (TREE_CODE (op) == SSA_NAME) |
1132 SSA_NAME_DEF_STMT (op) = stmt; | 1156 SSA_NAME_DEF_STMT (op) = stmt; |
1133 } | 1157 } |
1134 } | 1158 } |
1135 | 1159 |
1160 /* Reset alias information. */ | |
1161 if (code == GIMPLE_CALL) | |
1162 gimple_call_reset_alias_info (stmt); | |
1163 | |
1136 /* Fixup reference tree operands for substituted prevailing decls | 1164 /* Fixup reference tree operands for substituted prevailing decls |
1137 with mismatched types. */ | 1165 with mismatched types. */ |
1138 maybe_fixup_decls (stmt); | 1166 maybe_fixup_decls (stmt); |
1139 | 1167 |
1140 /* Mark the statement modified so its operand vectors can be filled in. */ | 1168 /* Mark the statement modified so its operand vectors can be filled in. */ |
1217 static void | 1245 static void |
1218 fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple *stmts) | 1246 fixup_call_stmt_edges_1 (struct cgraph_node *node, gimple *stmts) |
1219 { | 1247 { |
1220 struct cgraph_edge *cedge; | 1248 struct cgraph_edge *cedge; |
1221 for (cedge = node->callees; cedge; cedge = cedge->next_callee) | 1249 for (cedge = node->callees; cedge; cedge = cedge->next_callee) |
1250 cedge->call_stmt = stmts[cedge->lto_stmt_uid]; | |
1251 for (cedge = node->indirect_calls; cedge; cedge = cedge->next_callee) | |
1222 cedge->call_stmt = stmts[cedge->lto_stmt_uid]; | 1252 cedge->call_stmt = stmts[cedge->lto_stmt_uid]; |
1223 } | 1253 } |
1224 | 1254 |
1225 /* Fixup call_stmt pointers in NODE and all clones. */ | 1255 /* Fixup call_stmt pointers in NODE and all clones. */ |
1226 | 1256 |
1284 fn->dont_save_pending_sizes_p = bp_unpack_value (bp, 1); | 1314 fn->dont_save_pending_sizes_p = bp_unpack_value (bp, 1); |
1285 fn->stdarg = bp_unpack_value (bp, 1); | 1315 fn->stdarg = bp_unpack_value (bp, 1); |
1286 fn->has_nonlocal_label = bp_unpack_value (bp, 1); | 1316 fn->has_nonlocal_label = bp_unpack_value (bp, 1); |
1287 fn->calls_alloca = bp_unpack_value (bp, 1); | 1317 fn->calls_alloca = bp_unpack_value (bp, 1); |
1288 fn->calls_setjmp = bp_unpack_value (bp, 1); | 1318 fn->calls_setjmp = bp_unpack_value (bp, 1); |
1289 fn->function_frequency = (enum function_frequency) bp_unpack_value (bp, 2); | |
1290 fn->va_list_fpr_size = bp_unpack_value (bp, 8); | 1319 fn->va_list_fpr_size = bp_unpack_value (bp, 8); |
1291 fn->va_list_gpr_size = bp_unpack_value (bp, 8); | 1320 fn->va_list_gpr_size = bp_unpack_value (bp, 8); |
1292 bitpack_delete (bp); | 1321 bitpack_delete (bp); |
1322 | |
1323 /* Input the current IL state of the function. */ | |
1324 fn->curr_properties = lto_input_uleb128 (ib); | |
1293 | 1325 |
1294 /* Read the static chain and non-local goto save area. */ | 1326 /* Read the static chain and non-local goto save area. */ |
1295 fn->static_chain_decl = lto_input_tree (ib, data_in); | 1327 fn->static_chain_decl = lto_input_tree (ib, data_in); |
1296 fn->nonlocal_goto_save_area = lto_input_tree (ib, data_in); | 1328 fn->nonlocal_goto_save_area = lto_input_tree (ib, data_in); |
1297 | 1329 |
1464 input_function (fn_decl, data_in, &ib_main); | 1496 input_function (fn_decl, data_in, &ib_main); |
1465 | 1497 |
1466 /* We should now be in SSA. */ | 1498 /* We should now be in SSA. */ |
1467 cfun->gimple_df->in_ssa_p = true; | 1499 cfun->gimple_df->in_ssa_p = true; |
1468 | 1500 |
1469 /* Fill in properties we know hold for the rebuilt CFG. */ | |
1470 cfun->curr_properties = PROP_ssa | |
1471 | PROP_cfg | |
1472 | PROP_gimple_any | |
1473 | PROP_gimple_lcf | |
1474 | PROP_gimple_leh | |
1475 | PROP_referenced_vars; | |
1476 | |
1477 /* Restore decl state */ | 1501 /* Restore decl state */ |
1478 file_data->current_decl_state = file_data->global_decl_state; | 1502 file_data->current_decl_state = file_data->global_decl_state; |
1479 | 1503 |
1480 pop_cfun (); | 1504 pop_cfun (); |
1481 } | 1505 } |
1518 get_resolution (struct data_in *data_in, unsigned index) | 1542 get_resolution (struct data_in *data_in, unsigned index) |
1519 { | 1543 { |
1520 if (data_in->globals_resolution) | 1544 if (data_in->globals_resolution) |
1521 { | 1545 { |
1522 ld_plugin_symbol_resolution_t ret; | 1546 ld_plugin_symbol_resolution_t ret; |
1523 gcc_assert (index < VEC_length (ld_plugin_symbol_resolution_t, | 1547 /* We can have references to not emitted functions in |
1524 data_in->globals_resolution)); | 1548 DECL_FUNCTION_PERSONALITY at least. So we can and have |
1549 to indeed return LDPR_UNKNOWN in some cases. */ | |
1550 if (VEC_length (ld_plugin_symbol_resolution_t, | |
1551 data_in->globals_resolution) <= index) | |
1552 return LDPR_UNKNOWN; | |
1525 ret = VEC_index (ld_plugin_symbol_resolution_t, | 1553 ret = VEC_index (ld_plugin_symbol_resolution_t, |
1526 data_in->globals_resolution, | 1554 data_in->globals_resolution, |
1527 index); | 1555 index); |
1528 gcc_assert (ret != LDPR_UNKNOWN); | |
1529 return ret; | 1556 return ret; |
1530 } | 1557 } |
1531 else | 1558 else |
1532 /* Delay resolution finding until decl merging. */ | 1559 /* Delay resolution finding until decl merging. */ |
1533 return LDPR_UNKNOWN; | 1560 return LDPR_UNKNOWN; |
1691 | 1718 |
1692 if (TREE_CODE (expr) == VAR_DECL) | 1719 if (TREE_CODE (expr) == VAR_DECL) |
1693 { | 1720 { |
1694 DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1); | 1721 DECL_HARD_REGISTER (expr) = (unsigned) bp_unpack_value (bp, 1); |
1695 DECL_IN_TEXT_SECTION (expr) = (unsigned) bp_unpack_value (bp, 1); | 1722 DECL_IN_TEXT_SECTION (expr) = (unsigned) bp_unpack_value (bp, 1); |
1723 DECL_IN_CONSTANT_POOL (expr) = (unsigned) bp_unpack_value (bp, 1); | |
1696 DECL_TLS_MODEL (expr) = (enum tls_model) bp_unpack_value (bp, 3); | 1724 DECL_TLS_MODEL (expr) = (enum tls_model) bp_unpack_value (bp, 3); |
1697 } | 1725 } |
1698 | 1726 |
1699 if (VAR_OR_FUNCTION_DECL_P (expr)) | 1727 if (VAR_OR_FUNCTION_DECL_P (expr)) |
1700 { | 1728 { |
1744 TYPE_PRECISION (expr) = (unsigned) bp_unpack_value (bp, 9); | 1772 TYPE_PRECISION (expr) = (unsigned) bp_unpack_value (bp, 9); |
1745 mode = (enum machine_mode) bp_unpack_value (bp, 7); | 1773 mode = (enum machine_mode) bp_unpack_value (bp, 7); |
1746 SET_TYPE_MODE (expr, mode); | 1774 SET_TYPE_MODE (expr, mode); |
1747 TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1); | 1775 TYPE_STRING_FLAG (expr) = (unsigned) bp_unpack_value (bp, 1); |
1748 TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1); | 1776 TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1); |
1749 TYPE_NEEDS_CONSTRUCTING(expr) = (unsigned) bp_unpack_value (bp, 1); | 1777 TYPE_NEEDS_CONSTRUCTING (expr) = (unsigned) bp_unpack_value (bp, 1); |
1750 if (TREE_CODE (expr) == UNION_TYPE) | 1778 if (RECORD_OR_UNION_TYPE_P (expr)) |
1751 TYPE_TRANSPARENT_UNION (expr) = (unsigned) bp_unpack_value (bp, 1); | 1779 TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1); |
1752 TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1); | 1780 TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1); |
1753 TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1); | 1781 TYPE_RESTRICT (expr) = (unsigned) bp_unpack_value (bp, 1); |
1754 TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr) | 1782 TYPE_CONTAINS_PLACEHOLDER_INTERNAL (expr) |
1755 = (unsigned) bp_unpack_value (bp, 2); | 1783 = (unsigned) bp_unpack_value (bp, 2); |
1756 TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1); | 1784 TYPE_USER_ALIGN (expr) = (unsigned) bp_unpack_value (bp, 1); |
2137 { | 2165 { |
2138 if (TREE_CODE (expr) == ENUMERAL_TYPE) | 2166 if (TREE_CODE (expr) == ENUMERAL_TYPE) |
2139 TYPE_VALUES (expr) = lto_input_tree (ib, data_in); | 2167 TYPE_VALUES (expr) = lto_input_tree (ib, data_in); |
2140 else if (TREE_CODE (expr) == ARRAY_TYPE) | 2168 else if (TREE_CODE (expr) == ARRAY_TYPE) |
2141 TYPE_DOMAIN (expr) = lto_input_tree (ib, data_in); | 2169 TYPE_DOMAIN (expr) = lto_input_tree (ib, data_in); |
2142 else if (TREE_CODE (expr) == RECORD_TYPE || TREE_CODE (expr) == UNION_TYPE) | 2170 else if (RECORD_OR_UNION_TYPE_P (expr)) |
2143 TYPE_FIELDS (expr) = lto_input_tree (ib, data_in); | 2171 TYPE_FIELDS (expr) = lto_input_tree (ib, data_in); |
2144 else if (TREE_CODE (expr) == FUNCTION_TYPE || TREE_CODE (expr) == METHOD_TYPE) | 2172 else if (TREE_CODE (expr) == FUNCTION_TYPE |
2173 || TREE_CODE (expr) == METHOD_TYPE) | |
2145 TYPE_ARG_TYPES (expr) = lto_input_tree (ib, data_in); | 2174 TYPE_ARG_TYPES (expr) = lto_input_tree (ib, data_in); |
2146 else if (TREE_CODE (expr) == VECTOR_TYPE) | 2175 else if (TREE_CODE (expr) == VECTOR_TYPE) |
2147 TYPE_DEBUG_REPRESENTATION_TYPE (expr) = lto_input_tree (ib, data_in); | 2176 TYPE_DEBUG_REPRESENTATION_TYPE (expr) = lto_input_tree (ib, data_in); |
2148 | 2177 |
2149 TYPE_SIZE (expr) = lto_input_tree (ib, data_in); | 2178 TYPE_SIZE (expr) = lto_input_tree (ib, data_in); |