diff mbox

[i386,Pointer,Bounds,Checker,12/x] Recognize instrumented special functions

Message ID 20140529110002.GA30323@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich May 29, 2014, 11 a.m. UTC
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.enkovich@intel.com>

	* calls.c (special_function_p): Use original decl name
	when analyzing instrumentation clone.

Comments

Jeff Law May 30, 2014, 4:46 p.m. UTC | #1
On 05/29/14 05:00, Ilya Enkovich wrote:
> 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.enkovich@intel.com>
>
> 	* calls.c (special_function_p): Use original decl name
> 	when analyzing instrumentation clone.
OK for the trunk when the rest of the patches are approved.

Presumably we have to use the original decl because we twiddle the name 
in the clones, right?  Just want to make sure I understand why we're 
dong this :-)


jeff
Ilya Enkovich June 2, 2014, 10:38 a.m. UTC | #2
On 30 May 10:46, Jeff Law wrote:
> On 05/29/14 05:00, Ilya Enkovich wrote:
> >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.enkovich@intel.com>
> >
> >	* calls.c (special_function_p): Use original decl name
> >	when analyzing instrumentation clone.
> OK for the trunk when the rest of the patches are approved.
> 
> Presumably we have to use the original decl because we twiddle the
> name in the clones, right?  Just want to make sure I understand why
> we're dong this :-)
That's right. We add ".chkp" prefix for all instrumented functions to keep assembler name unique during compilation. Otherwise it becomes a mess with LTO.

Ilya
> 
> 
> jeff
>
diff mbox

Patch

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;