Mercurial > hg > CbC > CbC_gcc
comparison gcc/lto/lto-lang.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 |
---|---|
1 /* Language-dependent hooks for LTO. | 1 /* Language-dependent hooks for LTO. |
2 Copyright 2009 Free Software Foundation, Inc. | 2 Copyright 2009, 2010 Free Software Foundation, Inc. |
3 Contributed by CodeSourcery, Inc. | 3 Contributed by CodeSourcery, Inc. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
22 #include "system.h" | 22 #include "system.h" |
23 #include "coretypes.h" | 23 #include "coretypes.h" |
24 #include "flags.h" | 24 #include "flags.h" |
25 #include "tm.h" | 25 #include "tm.h" |
26 #include "tree.h" | 26 #include "tree.h" |
27 #include "expr.h" | |
28 #include "target.h" | 27 #include "target.h" |
29 #include "langhooks.h" | 28 #include "langhooks.h" |
30 #include "langhooks-def.h" | 29 #include "langhooks-def.h" |
31 #include "debug.h" | 30 #include "debug.h" |
32 #include "lto-tree.h" | 31 #include "lto-tree.h" |
33 #include "lto.h" | 32 #include "lto.h" |
34 #include "tree-inline.h" | 33 #include "tree-inline.h" |
35 #include "gimple.h" | 34 #include "gimple.h" |
35 #include "diagnostic-core.h" | |
36 #include "toplev.h" | 36 #include "toplev.h" |
37 #include "lto-streamer.h" | |
37 | 38 |
38 static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *); | 39 static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *); |
40 static tree handle_leaf_attribute (tree *, tree, tree, int, bool *); | |
39 static tree handle_const_attribute (tree *, tree, tree, int, bool *); | 41 static tree handle_const_attribute (tree *, tree, tree, int, bool *); |
40 static tree handle_malloc_attribute (tree *, tree, tree, int, bool *); | 42 static tree handle_malloc_attribute (tree *, tree, tree, int, bool *); |
41 static tree handle_pure_attribute (tree *, tree, tree, int, bool *); | 43 static tree handle_pure_attribute (tree *, tree, tree, int, bool *); |
42 static tree handle_novops_attribute (tree *, tree, tree, int, bool *); | 44 static tree handle_novops_attribute (tree *, tree, tree, int, bool *); |
43 static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *); | 45 static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *); |
51 const struct attribute_spec lto_attribute_table[] = | 53 const struct attribute_spec lto_attribute_table[] = |
52 { | 54 { |
53 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */ | 55 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */ |
54 { "noreturn", 0, 0, true, false, false, | 56 { "noreturn", 0, 0, true, false, false, |
55 handle_noreturn_attribute }, | 57 handle_noreturn_attribute }, |
58 { "leaf", 0, 0, true, false, false, | |
59 handle_leaf_attribute }, | |
56 /* The same comments as for noreturn attributes apply to const ones. */ | 60 /* The same comments as for noreturn attributes apply to const ones. */ |
57 { "const", 0, 0, true, false, false, | 61 { "const", 0, 0, true, false, false, |
58 handle_const_attribute }, | 62 handle_const_attribute }, |
59 { "malloc", 0, 0, true, false, false, | 63 { "malloc", 0, 0, true, false, false, |
60 handle_malloc_attribute }, | 64 handle_malloc_attribute }, |
153 static GTY(()) tree intmax_type_node; | 157 static GTY(()) tree intmax_type_node; |
154 static GTY(()) tree uintmax_type_node; | 158 static GTY(()) tree uintmax_type_node; |
155 static GTY(()) tree signed_size_type_node; | 159 static GTY(()) tree signed_size_type_node; |
156 | 160 |
157 /* Flags needed to process builtins.def. */ | 161 /* Flags needed to process builtins.def. */ |
158 int flag_no_builtin; | |
159 int flag_no_nonansi_builtin; | |
160 int flag_isoc94; | 162 int flag_isoc94; |
161 int flag_isoc99; | 163 int flag_isoc99; |
162 | 164 |
163 /* Attribute handlers. */ | 165 /* Attribute handlers. */ |
164 | 166 |
184 gcc_unreachable (); | 186 gcc_unreachable (); |
185 | 187 |
186 return NULL_TREE; | 188 return NULL_TREE; |
187 } | 189 } |
188 | 190 |
191 /* Handle a "leaf" attribute; arguments as in | |
192 struct attribute_spec.handler. */ | |
193 | |
194 static tree | |
195 handle_leaf_attribute (tree *node, tree name, | |
196 tree ARG_UNUSED (args), | |
197 int ARG_UNUSED (flags), bool *no_add_attrs) | |
198 { | |
199 if (TREE_CODE (*node) != FUNCTION_DECL) | |
200 { | |
201 warning (OPT_Wattributes, "%qE attribute ignored", name); | |
202 *no_add_attrs = true; | |
203 } | |
204 if (!TREE_PUBLIC (*node)) | |
205 { | |
206 warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name); | |
207 *no_add_attrs = true; | |
208 } | |
209 | |
210 return NULL_TREE; | |
211 } | |
189 | 212 |
190 /* Handle a "const" attribute; arguments as in | 213 /* Handle a "const" attribute; arguments as in |
191 struct attribute_spec.handler. */ | 214 struct attribute_spec.handler. */ |
192 | 215 |
193 static tree | 216 static tree |
289 /* If no arguments are specified, all pointer arguments should be | 312 /* If no arguments are specified, all pointer arguments should be |
290 non-null. Verify a full prototype is given so that the arguments | 313 non-null. Verify a full prototype is given so that the arguments |
291 will have the correct types when we actually check them later. */ | 314 will have the correct types when we actually check them later. */ |
292 if (!args) | 315 if (!args) |
293 { | 316 { |
294 gcc_assert (TYPE_ARG_TYPES (type)); | 317 gcc_assert (prototype_p (type)); |
295 return NULL_TREE; | 318 return NULL_TREE; |
296 } | 319 } |
297 | 320 |
298 /* Argument list specified. Verify that each argument number references | 321 /* Argument list specified. Verify that each argument number references |
299 a pointer argument. */ | 322 a pointer argument. */ |
595 static GTY(()) tree registered_builtin_fndecls; | 618 static GTY(()) tree registered_builtin_fndecls; |
596 | 619 |
597 /* Language hooks. */ | 620 /* Language hooks. */ |
598 | 621 |
599 static unsigned int | 622 static unsigned int |
600 lto_init_options (unsigned int argc ATTRIBUTE_UNUSED, | 623 lto_option_lang_mask (void) |
601 const char **argv ATTRIBUTE_UNUSED) | 624 { |
625 return CL_LTO; | |
626 } | |
627 | |
628 static bool | |
629 lto_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED) | |
630 { | |
631 /* The LTO front end inherits all the options from the first front | |
632 end that was used. However, not all the original front end | |
633 options make sense in LTO. | |
634 | |
635 A real solution would be to filter this in collect2, but collect2 | |
636 does not have access to all the option attributes to know what to | |
637 filter. So, in lto1 we silently accept inherited flags and do | |
638 nothing about it. */ | |
639 return false; | |
640 } | |
641 | |
642 static void | |
643 lto_init_options_struct (struct gcc_options *opts) | |
602 { | 644 { |
603 /* By default, C99-like requirements for complex multiply and divide. | 645 /* By default, C99-like requirements for complex multiply and divide. |
604 ??? Until the complex method is encoded in the IL this is the only | 646 ??? Until the complex method is encoded in the IL this is the only |
605 safe choice. This will pessimize Fortran code with LTO unless | 647 safe choice. This will pessimize Fortran code with LTO unless |
606 people specify a complex method manually or use -ffast-math. */ | 648 people specify a complex method manually or use -ffast-math. */ |
607 flag_complex_method = 2; | 649 opts->x_flag_complex_method = 2; |
608 | |
609 return CL_LTO; | |
610 } | 650 } |
611 | 651 |
612 /* Handle command-line option SCODE. If the option takes an argument, it is | 652 /* Handle command-line option SCODE. If the option takes an argument, it is |
613 stored in ARG, which is otherwise NULL. VALUE holds either a numerical | 653 stored in ARG, which is otherwise NULL. VALUE holds either a numerical |
614 argument or a binary value indicating whether the positive or negative form | 654 argument or a binary value indicating whether the positive or negative form |
615 of the option was supplied. */ | 655 of the option was supplied. */ |
616 | 656 |
617 const char *resolution_file_name; | 657 const char *resolution_file_name; |
618 static int | 658 static bool |
619 lto_handle_option (size_t scode, const char *arg, | 659 lto_handle_option (size_t scode, const char *arg, |
620 int value ATTRIBUTE_UNUSED, int kind ATTRIBUTE_UNUSED) | 660 int value ATTRIBUTE_UNUSED, int kind ATTRIBUTE_UNUSED, |
661 location_t loc ATTRIBUTE_UNUSED, | |
662 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED) | |
621 { | 663 { |
622 enum opt_code code = (enum opt_code) scode; | 664 enum opt_code code = (enum opt_code) scode; |
623 int result = 1; | 665 bool result = true; |
624 | 666 |
625 switch (code) | 667 switch (code) |
626 { | 668 { |
627 case OPT_fresolution_: | 669 case OPT_fresolution_: |
628 resolution_file_name = arg; | 670 resolution_file_name = arg; |
629 result = 1; | |
630 break; | 671 break; |
631 | 672 |
632 case OPT_Wabi: | 673 case OPT_Wabi: |
633 warn_psabi = value; | 674 warn_psabi = value; |
634 break; | |
635 | |
636 case OPT_fsigned_char: | |
637 flag_signed_char = value; | |
638 break; | |
639 | |
640 case OPT_funsigned_char: | |
641 flag_signed_char = !value; | |
642 break; | 675 break; |
643 | 676 |
644 default: | 677 default: |
645 break; | 678 break; |
646 } | 679 } |
1108 } | 1141 } |
1109 | 1142 |
1110 targetm.init_builtins (); | 1143 targetm.init_builtins (); |
1111 build_common_builtin_nodes (); | 1144 build_common_builtin_nodes (); |
1112 | 1145 |
1146 /* Assign names to the builtin types, otherwise they'll end up | |
1147 as __unknown__ in debug info. | |
1148 ??? We simply need to stop pre-seeding the streamer cache. | |
1149 Below is modeled after from c-common.c:c_common_nodes_and_builtins */ | |
1150 #define NAME_TYPE(t,n) \ | |
1151 if (t) \ | |
1152 TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL, \ | |
1153 get_identifier (n), t) | |
1154 NAME_TYPE (integer_type_node, "int"); | |
1155 NAME_TYPE (char_type_node, "char"); | |
1156 NAME_TYPE (long_integer_type_node, "long int"); | |
1157 NAME_TYPE (unsigned_type_node, "unsigned int"); | |
1158 NAME_TYPE (long_unsigned_type_node, "long unsigned int"); | |
1159 NAME_TYPE (long_long_integer_type_node, "long long int"); | |
1160 NAME_TYPE (long_long_unsigned_type_node, "long long unsigned int"); | |
1161 NAME_TYPE (short_integer_type_node, "short int"); | |
1162 NAME_TYPE (short_unsigned_type_node, "short unsigned int"); | |
1163 if (signed_char_type_node != char_type_node) | |
1164 NAME_TYPE (signed_char_type_node, "signed char"); | |
1165 if (unsigned_char_type_node != char_type_node) | |
1166 NAME_TYPE (unsigned_char_type_node, "unsigned char"); | |
1167 NAME_TYPE (float_type_node, "float"); | |
1168 NAME_TYPE (double_type_node, "double"); | |
1169 NAME_TYPE (long_double_type_node, "long double"); | |
1170 NAME_TYPE (void_type_node, "void"); | |
1171 NAME_TYPE (boolean_type_node, "bool"); | |
1172 #undef NAME_TYPE | |
1173 | |
1113 /* Initialize LTO-specific data structures. */ | 1174 /* Initialize LTO-specific data structures. */ |
1114 lto_global_var_decls = VEC_alloc (tree, gc, 256); | 1175 lto_global_var_decls = VEC_alloc (tree, gc, 256); |
1115 in_lto_p = true; | 1176 in_lto_p = true; |
1116 | 1177 |
1117 return true; | 1178 return true; |
1124 tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1; | 1185 tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1; |
1125 } | 1186 } |
1126 | 1187 |
1127 #undef LANG_HOOKS_NAME | 1188 #undef LANG_HOOKS_NAME |
1128 #define LANG_HOOKS_NAME "GNU GIMPLE" | 1189 #define LANG_HOOKS_NAME "GNU GIMPLE" |
1129 #undef LANG_HOOKS_INIT_OPTIONS | 1190 #undef LANG_HOOKS_OPTION_LANG_MASK |
1130 #define LANG_HOOKS_INIT_OPTIONS lto_init_options | 1191 #define LANG_HOOKS_OPTION_LANG_MASK lto_option_lang_mask |
1192 #undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P | |
1193 #define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lto_complain_wrong_lang_p | |
1194 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT | |
1195 #define LANG_HOOKS_INIT_OPTIONS_STRUCT lto_init_options_struct | |
1131 #undef LANG_HOOKS_HANDLE_OPTION | 1196 #undef LANG_HOOKS_HANDLE_OPTION |
1132 #define LANG_HOOKS_HANDLE_OPTION lto_handle_option | 1197 #define LANG_HOOKS_HANDLE_OPTION lto_handle_option |
1133 #undef LANG_HOOKS_POST_OPTIONS | 1198 #undef LANG_HOOKS_POST_OPTIONS |
1134 #define LANG_HOOKS_POST_OPTIONS lto_post_options | 1199 #define LANG_HOOKS_POST_OPTIONS lto_post_options |
1135 #undef LANG_HOOKS_GET_ALIAS_SET | 1200 #undef LANG_HOOKS_GET_ALIAS_SET |
1160 #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION tree_rest_of_compilation | 1225 #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION tree_rest_of_compilation |
1161 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS | 1226 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS |
1162 #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true | 1227 #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true |
1163 #undef LANG_HOOKS_TYPES_COMPATIBLE_P | 1228 #undef LANG_HOOKS_TYPES_COMPATIBLE_P |
1164 #define LANG_HOOKS_TYPES_COMPATIBLE_P NULL | 1229 #define LANG_HOOKS_TYPES_COMPATIBLE_P NULL |
1230 #undef LANG_HOOKS_EH_PERSONALITY | |
1231 #define LANG_HOOKS_EH_PERSONALITY lto_eh_personality | |
1165 | 1232 |
1166 /* Attribute hooks. */ | 1233 /* Attribute hooks. */ |
1167 #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE | 1234 #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE |
1168 #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE lto_attribute_table | 1235 #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE lto_attribute_table |
1169 #undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE | 1236 #undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE |