public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386, Pointer Bounds Checker 12/x] Recognize instrumented special functions
@ 2014-05-29 11:00 Ilya Enkovich
  2014-05-30 16:46 ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Enkovich @ 2014-05-29 11:00 UTC (permalink / raw)
  To: gcc-patches

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.

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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, i386, Pointer Bounds Checker 12/x] Recognize instrumented special functions
  2014-05-29 11:00 [PATCH, i386, Pointer Bounds Checker 12/x] Recognize instrumented special functions Ilya Enkovich
@ 2014-05-30 16:46 ` Jeff Law
  2014-06-02 10:38   ` Ilya Enkovich
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2014-05-30 16:46 UTC (permalink / raw)
  To: Ilya Enkovich, gcc-patches

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH, i386, Pointer Bounds Checker 12/x] Recognize instrumented special functions
  2014-05-30 16:46 ` Jeff Law
@ 2014-06-02 10:38   ` Ilya Enkovich
  0 siblings, 0 replies; 3+ messages in thread
From: Ilya Enkovich @ 2014-06-02 10:38 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-02 10:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-29 11:00 [PATCH, i386, Pointer Bounds Checker 12/x] Recognize instrumented special functions Ilya Enkovich
2014-05-30 16:46 ` Jeff Law
2014-06-02 10:38   ` Ilya Enkovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).