aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2018-12-15 22:24:52 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2018-12-15 21:24:52 +0000
commitf714ecf522782f76d7d9d9826fe1bcd23259cf24 (patch)
treecad3aa0fcf39b65a7a9442f8e128039691dc8f65 /gcc/cgraph.c
parent6263c29d28abb099cb835ca373aa234ef36df6a2 (diff)
downloadgcc-f714ecf522782f76d7d9d9826fe1bcd23259cf24.zip
gcc-f714ecf522782f76d7d9d9826fe1bcd23259cf24.tar.gz
gcc-f714ecf522782f76d7d9d9826fe1bcd23259cf24.tar.bz2
cgraph.h (cgraph_node): Add predicate prevailing_p.
* cgraph.h (cgraph_node): Add predicate prevailing_p. (cgraph_edge): Add predicate possible_call_in_translation_unit_p. * ipa-prop.c (ipa_write_jump_function): Optimize streaming of ADDR_EXPR. (ipa_read_jump_function): Add prevails parameter; optimize streaming. (ipa_read_edge_info): Break out from ... (ipa_read_node_info): ... here; optimize streaming. * cgraph.c (cgraph_edge::possibly_call_in_translation_unit_p): New predicate. From-SVN: r267175
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index b3dd429..850a9b6 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3766,6 +3766,41 @@ cgraph_edge::sreal_frequency ()
: caller->count);
}
+
+/* During LTO stream in this can be used to check whether call can possibly
+ be internal to the current translation unit. */
+
+bool
+cgraph_edge::possibly_call_in_translation_unit_p (void)
+{
+ gcc_checking_assert (in_lto_p && caller->prevailing_p ());
+
+ /* While incremental linking we may end up getting function body later. */
+ if (flag_incremental_link == INCREMENTAL_LINK_LTO)
+ return true;
+
+ /* We may be smarter here and avoid stremaing in indirect calls we can't
+ track, but that would require arranging stremaing the indirect call
+ summary first. */
+ if (!callee)
+ return true;
+
+ /* If calle is local to the original translation unit, it will be defined. */
+ if (!TREE_PUBLIC (callee->decl) && !DECL_EXTERNAL (callee->decl))
+ return true;
+
+ /* Otherwise we need to lookup prevailing symbol (symbol table is not merged,
+ yet) and see if it is a definition. In fact we may also resolve aliases,
+ but that is probably not too important. */
+ symtab_node *node = callee;
+ for (int n = 10; node->previous_sharing_asm_name && n ; n--)
+ node = node->previous_sharing_asm_name;
+ if (node->previous_sharing_asm_name)
+ node = symtab_node::get_for_asmname (DECL_ASSEMBLER_NAME (callee->decl));
+ gcc_assert (TREE_PUBLIC (node->decl));
+ return node->get_availability () >= AVAIL_AVAILABLE;
+}
+
/* A stashed copy of "symtab" for use by selftest::symbol_table_test.
This needs to be a global so that it can be a GC root, and thus
prevent the stashed copy from being garbage-collected if the GC runs