This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, Pointer Bounds Checker, Builtins instrumentation 2/5] Instrument builtin calls


On 11/14/14 01:06, Ilya Enkovich wrote:

-  /* Avoid instrumented builtin functions for now.  Due to IPA
-     it also means we have to avoid instrumentation of indirect
-     calls.  */
-  if (fndecl && DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN)
-    return;
+  /* We instrument only some subset of builtins.  We also instrument
+     builtin calls to be inlined.  */
+  if (fndecl
+      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
+      && !chkp_instrument_normal_builtin (fndecl))
+    {
+      struct cgraph_node *clone = chkp_maybe_create_clone (fndecl);
+      if (!clone
+         || !gimple_has_body_p (clone->decl)
+         || !lookup_attribute ("always_inline", DECL_ATTRIBUTES
(fndecl)))
+       return;
+    }

Is that outer conditional right?  If we have a fndecl and it's a normal
builtin, but it's _not_ one of hte builtins we're instrumenting, then call
chkp_maybe_create_clone?

Some builtin functions (especially their *_chk version) are defined as
always_inline functions in headers.  In this case we handle them as
regular functions (clone and instrument) because they will be inlined
anyway. Seems gimple_has_body_p should be applied to fndecl and moved
into outer if-statement along with attribute check.  Thus unneeded
clones would be avoided.
So the outer condition is, essentially checking for a _chk builtin and if we find it, try to create a clone for instrumentation purposes.

I think the always_inline attribute lookup can move to the outer-if. Less sure about the gimple_has_body check though. Presumably clone->decl is going to refer to fndecl? If so, then that can move to the outer if as well. As you say, that may cut down on the number of clones that get created.

OK as-is, or with those two conditions moved out of level as long as all prerequisites are approved and it passes a bootstrap & regression test.

JEff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]