diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2018-02-08 15:51:51 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2018-02-08 14:51:51 +0000 |
commit | 39aa9b2369eff7f2be0712ea7f1ee12f8697ce36 (patch) | |
tree | 09190fc346352b0770f0eab06a1b4031cf5bb35d /gcc/symtab.c | |
parent | 84b4c7b593cd4ebb475a08aa4b816c722f716ce6 (diff) | |
download | gcc-39aa9b2369eff7f2be0712ea7f1ee12f8697ce36.zip gcc-39aa9b2369eff7f2be0712ea7f1ee12f8697ce36.tar.gz gcc-39aa9b2369eff7f2be0712ea7f1ee12f8697ce36.tar.bz2 |
re PR ipa/81360 (ice in estimate_edge_growth, at ipa-inline.h:86)
PR ipa/81360
* cgraph.h (symtab_node::output_to_lto_symbol_table_p): Declare
* symtab.c: Include builtins.h
(symtab_node::output_to_lto_symbol_table_p): Move here
from lto-streamer-out.c:output_symbol_p.
* lto-streamer-out.c (write_symbol): Turn early exit to assert.
(output_symbol_p): Move all logic to symtab.c
(produce_symtab): Update.
* lto.c (unify_scc): Register prevailing trees, not trees to be freed.
(read_cgraph_and_symbols): Use
symtab_node::output_to_lto_symbol_table_p.
From-SVN: r257490
Diffstat (limited to 'gcc/symtab.c')
-rw-r--r-- | gcc/symtab.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/symtab.c b/gcc/symtab.c index ff827cb..b54183f 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see #include "calls.h" #include "stringpool.h" #include "attribs.h" +#include "builtins.h" static const char *ipa_ref_use_name[] = {"read","write","addr","alias","chkp"}; @@ -2292,3 +2293,58 @@ symtab_node::binds_to_current_def_p (symtab_node *ref) return false; } + +/* Return true if symbol should be output to the symbol table. */ + +bool +symtab_node::output_to_lto_symbol_table_p (void) +{ + /* Only externally visible symbols matter. */ + if (!TREE_PUBLIC (decl)) + return false; + if (!real_symbol_p ()) + return false; + /* FIXME: variables probably should not be considered as real symbols at + first place. */ + if (VAR_P (decl) && DECL_HARD_REGISTER (decl)) + return false; + /* FIXME: Builtins corresponding to real functions probably should have + symbol table entries. */ + if (is_builtin_fn (decl)) + return false; + + /* We have real symbol that should be in symbol table. However try to trim + down the refernces to libraries bit more because linker will otherwise + bring unnecesary object files into the final link. + FIXME: The following checks can easily be confused i.e. by self recursive + function or self-referring variable. */ + + /* We keep external functions in symtab for sake of inlining + and devirtualization. We do not want to see them in symbol table as + references unless they are really used. */ + cgraph_node *cnode = dyn_cast <cgraph_node *> (this); + if (cnode && (!definition || DECL_EXTERNAL (decl)) + && cnode->callers) + return true; + + /* Ignore all references from external vars initializers - they are not really + part of the compilation unit until they are used by folding. Some symbols, + like references to external construction vtables can not be referred to at + all. We decide this at can_refer_decl_in_current_unit_p. */ + if (!definition || DECL_EXTERNAL (decl)) + { + int i; + struct ipa_ref *ref; + for (i = 0; iterate_referring (i, ref); i++) + { + if (ref->use == IPA_REF_ALIAS) + continue; + if (is_a <cgraph_node *> (ref->referring)) + return true; + if (!DECL_EXTERNAL (ref->referring->decl)) + return true; + } + return false; + } + return true; +} |