Mercurial > hg > CbC > CbC_gcc
comparison gcc/symtab.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Symbol table. | 1 /* Symbol table. |
2 Copyright (C) 2012-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2012-2018 Free Software Foundation, Inc. |
3 Contributed by Jan Hubicka | 3 Contributed by Jan Hubicka |
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 |
35 #include "output.h" | 35 #include "output.h" |
36 #include "ipa-utils.h" | 36 #include "ipa-utils.h" |
37 #include "calls.h" | 37 #include "calls.h" |
38 #include "stringpool.h" | 38 #include "stringpool.h" |
39 #include "attribs.h" | 39 #include "attribs.h" |
40 | 40 #include "builtins.h" |
41 static const char *ipa_ref_use_name[] = {"read","write","addr","alias","chkp"}; | 41 |
42 static const char *ipa_ref_use_name[] = {"read","write","addr","alias"}; | |
42 | 43 |
43 const char * const ld_plugin_symbol_resolution_names[]= | 44 const char * const ld_plugin_symbol_resolution_names[]= |
44 { | 45 { |
45 "", | 46 "", |
46 "undef", | 47 "undef", |
944 fprintf (f, "Symbol table:\n\n"); | 945 fprintf (f, "Symbol table:\n\n"); |
945 FOR_EACH_SYMBOL (node) | 946 FOR_EACH_SYMBOL (node) |
946 node->dump (f); | 947 node->dump (f); |
947 } | 948 } |
948 | 949 |
950 DEBUG_FUNCTION void | |
951 symbol_table::debug (void) | |
952 { | |
953 dump (stderr); | |
954 } | |
955 | |
949 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME. | 956 /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME. |
950 Return NULL if there's no such node. */ | 957 Return NULL if there's no such node. */ |
951 | 958 |
952 symtab_node * | 959 symtab_node * |
953 symtab_node::get_for_asmname (const_tree asmname) | 960 symtab_node::get_for_asmname (const_tree asmname) |
987 if (is_a <cgraph_node *> (this)) | 994 if (is_a <cgraph_node *> (this)) |
988 { | 995 { |
989 if (TREE_CODE (decl) != FUNCTION_DECL) | 996 if (TREE_CODE (decl) != FUNCTION_DECL) |
990 { | 997 { |
991 error ("function symbol is not function"); | 998 error ("function symbol is not function"); |
999 error_found = true; | |
1000 } | |
1001 else if ((lookup_attribute ("ifunc", DECL_ATTRIBUTES (decl)) | |
1002 != NULL) | |
1003 != dyn_cast <cgraph_node *> (this)->ifunc_resolver) | |
1004 { | |
1005 error ("inconsistent `ifunc' attribute"); | |
992 error_found = true; | 1006 error_found = true; |
993 } | 1007 } |
994 } | 1008 } |
995 else if (is_a <varpool_node *> (this)) | 1009 else if (is_a <varpool_node *> (this)) |
996 { | 1010 { |
1943 { | 1957 { |
1944 refuse_visibility_changes = true; | 1958 refuse_visibility_changes = true; |
1945 return true; | 1959 return true; |
1946 } | 1960 } |
1947 | 1961 |
1948 /* If target is defined and not extern, we know it will be output and thus | 1962 /* If target is defined and either comdat or not extern, we know it will be |
1949 it will bind to non-NULL. | 1963 output and thus it will bind to non-NULL. |
1950 Play safe for flag_delete_null_pointer_checks where weak definition maye | 1964 Play safe for flag_delete_null_pointer_checks where weak definition may |
1951 be re-defined by NULL. */ | 1965 be re-defined by NULL. */ |
1952 if (definition && !DECL_EXTERNAL (decl) | 1966 if (definition && (!DECL_EXTERNAL (decl) || DECL_COMDAT (decl)) |
1953 && (flag_delete_null_pointer_checks || !DECL_WEAK (decl))) | 1967 && (flag_delete_null_pointer_checks || !DECL_WEAK (decl))) |
1954 { | 1968 { |
1955 if (!DECL_WEAK (decl)) | 1969 if (!DECL_WEAK (decl)) |
1956 refuse_visibility_changes = true; | 1970 refuse_visibility_changes = true; |
1957 return true; | 1971 return true; |
2189 /* Increase alignment of THIS to ALIGN. */ | 2203 /* Increase alignment of THIS to ALIGN. */ |
2190 | 2204 |
2191 void | 2205 void |
2192 symtab_node::increase_alignment (unsigned int align) | 2206 symtab_node::increase_alignment (unsigned int align) |
2193 { | 2207 { |
2194 gcc_assert (can_increase_alignment_p () && align < MAX_OFILE_ALIGNMENT); | 2208 gcc_assert (can_increase_alignment_p () && align <= MAX_OFILE_ALIGNMENT); |
2195 ultimate_alias_target()->call_for_symbol_and_aliases (increase_alignment_1, | 2209 ultimate_alias_target()->call_for_symbol_and_aliases (increase_alignment_1, |
2196 (void *)(size_t) align, | 2210 (void *)(size_t) align, |
2197 true); | 2211 true); |
2198 gcc_assert (DECL_ALIGN (decl) >= align); | 2212 gcc_assert (DECL_ALIGN (decl) >= align); |
2199 } | 2213 } |
2244 if (!definition) | 2258 if (!definition) |
2245 return false; | 2259 return false; |
2246 if (transparent_alias) | 2260 if (transparent_alias) |
2247 return definition | 2261 return definition |
2248 && get_alias_target()->binds_to_current_def_p (ref); | 2262 && get_alias_target()->binds_to_current_def_p (ref); |
2249 if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (decl))) | 2263 cgraph_node *cnode = dyn_cast <cgraph_node *> (this); |
2264 if (cnode && cnode->ifunc_resolver) | |
2250 return false; | 2265 return false; |
2251 if (decl_binds_to_current_def_p (decl)) | 2266 if (decl_binds_to_current_def_p (decl)) |
2252 return true; | 2267 return true; |
2253 | 2268 |
2254 /* Inline clones always binds locally. */ | 2269 /* Inline clones always binds locally. */ |
2255 cgraph_node *cnode = dyn_cast <cgraph_node *> (this); | |
2256 if (cnode && cnode->global.inlined_to) | 2270 if (cnode && cnode->global.inlined_to) |
2257 return true; | 2271 return true; |
2258 | 2272 |
2259 if (DECL_EXTERNAL (decl)) | 2273 if (DECL_EXTERNAL (decl)) |
2260 return false; | 2274 return false; |
2290 && get_comdat_group () == ref->get_comdat_group ()) | 2304 && get_comdat_group () == ref->get_comdat_group ()) |
2291 return true; | 2305 return true; |
2292 | 2306 |
2293 return false; | 2307 return false; |
2294 } | 2308 } |
2309 | |
2310 /* Return true if symbol should be output to the symbol table. */ | |
2311 | |
2312 bool | |
2313 symtab_node::output_to_lto_symbol_table_p (void) | |
2314 { | |
2315 /* Only externally visible symbols matter. */ | |
2316 if (!TREE_PUBLIC (decl)) | |
2317 return false; | |
2318 if (!real_symbol_p ()) | |
2319 return false; | |
2320 /* FIXME: variables probably should not be considered as real symbols at | |
2321 first place. */ | |
2322 if (VAR_P (decl) && DECL_HARD_REGISTER (decl)) | |
2323 return false; | |
2324 /* FIXME: Builtins corresponding to real functions probably should have | |
2325 symbol table entries. */ | |
2326 if (TREE_CODE (decl) == FUNCTION_DECL && fndecl_built_in_p (decl)) | |
2327 return false; | |
2328 | |
2329 /* We have real symbol that should be in symbol table. However try to trim | |
2330 down the refernces to libraries bit more because linker will otherwise | |
2331 bring unnecesary object files into the final link. | |
2332 FIXME: The following checks can easily be confused i.e. by self recursive | |
2333 function or self-referring variable. */ | |
2334 | |
2335 /* We keep external functions in symtab for sake of inlining | |
2336 and devirtualization. We do not want to see them in symbol table as | |
2337 references unless they are really used. */ | |
2338 cgraph_node *cnode = dyn_cast <cgraph_node *> (this); | |
2339 if (cnode && (!definition || DECL_EXTERNAL (decl)) | |
2340 && cnode->callers) | |
2341 return true; | |
2342 | |
2343 /* Ignore all references from external vars initializers - they are not really | |
2344 part of the compilation unit until they are used by folding. Some symbols, | |
2345 like references to external construction vtables can not be referred to at | |
2346 all. We decide this at can_refer_decl_in_current_unit_p. */ | |
2347 if (!definition || DECL_EXTERNAL (decl)) | |
2348 { | |
2349 int i; | |
2350 struct ipa_ref *ref; | |
2351 for (i = 0; iterate_referring (i, ref); i++) | |
2352 { | |
2353 if (ref->use == IPA_REF_ALIAS) | |
2354 continue; | |
2355 if (is_a <cgraph_node *> (ref->referring)) | |
2356 return true; | |
2357 if (!DECL_EXTERNAL (ref->referring->decl)) | |
2358 return true; | |
2359 } | |
2360 return false; | |
2361 } | |
2362 return true; | |
2363 } |