> On Tue, Feb 23, 2016 at 12:32 PM, Richard Biener <rguent...@suse.de> wrote: > > On Tue, 23 Feb 2016, Jan Hubicka wrote: > > > >> > > >> > Ok, so maybe a better question to symtab would be if there is an > >> > actual definition for what __builtin_FOO will call. Not really > >> > whether that definition is cfun. Of course all the fortify > >> > always-inline wrappers should not count as such (just in case > >> > the symtab code is confused about those). > >> > >> Also GNU extern inlines that are often used to deal special cases. > >> > > >> > So, > >> > > >> > bool symbol_table::have_definition (enum built_in_fn); > >> > > >> > ? Not sure how to best implement that either. asmname lookups are > >> > expensive ... > >> > >> I am back from China trip, so i can handle you patch if you want. > > Honza - ping. Can you please think of a symtab predicate that tells me > whether a cgraph node is an implementation for BUILT_IN_X? (see original > patch in this thread). > > It's before another GCC release and we're trying to improve QOI wise for > almost 3 releases now...
Hi, I hope the following should do the trick... Honza Index: cgraph.h =================================================================== --- cgraph.h (revision 245506) +++ cgraph.h (working copy) @@ -1214,6 +1214,9 @@ public: direct calls. */ bool can_remove_if_no_direct_calls_p (bool will_inline = false); + /* Return true if symbol can possibly alias with implementation of FNCODE. */ + bool implements(enum built_in_function fncode); + /* Return true when callgraph node is a function with Gimple body defined in current unit. Functions can also be define externally or they can be thunks with no Gimple representation. Index: cgraph.c =================================================================== --- cgraph.c (revision 245506) +++ cgraph.c (working copy) @@ -3814,4 +3814,45 @@ cgraph_node::has_thunk_p (cgraph_node *n return false; } +/* Return true if symbol can possibly alias with implementation of FNCODE. */ + +bool +cgraph_node::implements (enum built_in_function fncode) +{ + struct cgraph_node *node = ultimate_alias_target (); + tree name = builtin_decl_explicit (fncode); + + if (name) + name = DECL_ASSEMBLER_NAME (name); + else + name = NULL; + + if ((DECL_BUILT_IN (node->decl) + && DECL_BUILT_IN_CLASS (node->decl) == BUILT_IN_NORMAL + && DECL_FUNCTION_CODE (node->decl) == fncode) + || (name && DECL_ASSEMBLER_NAME_SET_P (node->decl) + && symbol_table::assembler_names_equal_p + (IDENTIFIER_POINTER (name), + IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME + (node->decl))))) + return true; + + ipa_ref *ref; + FOR_EACH_ALIAS (node, ref) + { + cgraph_node *alias = dyn_cast <cgraph_node *> (ref->referring); + if ((DECL_BUILT_IN (alias->decl) + && DECL_BUILT_IN_CLASS (alias->decl) == BUILT_IN_NORMAL + && DECL_FUNCTION_CODE (alias->decl) == fncode) + || (name && DECL_ASSEMBLER_NAME_SET_P (alias->decl) + && symbol_table::assembler_names_equal_p + (IDENTIFIER_POINTER (name), + IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME + (alias->decl))))) + return true; + } + + return false; +} + #include "gt-cgraph.h"