Hi, This patch allows to recognize instrumented call to special function by using the original function name for recognition.
Bootstrapped and tested on linux-x86_64. Thanks, Ilya -- gcc/ 2014-05-29 Ilya Enkovich <ilya.enkov...@intel.com> * calls.c (special_function_p): Use original decl name when analyzing instrumentation clone. diff --git a/gcc/calls.c b/gcc/calls.c index f0c92dd..e1dc8eb 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -502,8 +502,16 @@ emit_call_1 (rtx funexp, tree fntree ATTRIBUTE_UNUSED, tree fndecl ATTRIBUTE_UNU static int special_function_p (const_tree fndecl, int flags) { - if (fndecl && DECL_NAME (fndecl) - && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 17 + tree name_decl = DECL_NAME (fndecl); + + /* For instrumentation clones we want to derive flags + from the original name. */ + if (cgraph_get_node (fndecl) + && cgraph_get_node (fndecl)->instrumentation_clone) + name_decl = DECL_NAME (cgraph_get_node (fndecl)->orig_decl); + + if (fndecl && name_decl + && IDENTIFIER_LENGTH (name_decl) <= 17 /* Exclude functions not at the file scope, or not `extern', since they are not the magic functions we would otherwise think they are. @@ -515,16 +523,16 @@ special_function_p (const_tree fndecl, int flags) || TREE_CODE (DECL_CONTEXT (fndecl)) == TRANSLATION_UNIT_DECL) && TREE_PUBLIC (fndecl)) { - const char *name = IDENTIFIER_POINTER (DECL_NAME (fndecl)); + const char *name = IDENTIFIER_POINTER (name_decl); const char *tname = name; /* We assume that alloca will always be called by name. It makes no sense to pass it as a pointer-to-function to anything that does not understand its behavior. */ - if (((IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 6 + if (((IDENTIFIER_LENGTH (name_decl) == 6 && name[0] == 'a' && ! strcmp (name, "alloca")) - || (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 16 + || (IDENTIFIER_LENGTH (name_decl) == 16 && name[0] == '_' && ! strcmp (name, "__builtin_alloca")))) flags |= ECF_MAY_BE_ALLOCA;