diff mbox

[i386,Pointer,Bounds,Checker,18/x] Expand instrumented builtin function calls

Message ID 20141003084743.GB50375@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich Oct. 3, 2014, 8:47 a.m. UTC
Since we still don't have a final decision about how instrumented builtin functions would look like, I replace this patch with a new one which assumes we don't instrument them for now.  It only has an additional init for va_start and also makes sure there is no instrumented builtin calls.  All instrumented builtins related codes will go into a separate series.

Thanks,
Ilya
--
2014-10-03  Ilya Enkovich  <ilya.enkovich@intel.com>

	* builtins.c: Include tree-chkp.h and rtl-chkp.h.
	(std_expand_builtin_va_start): Init bounds for va_list.
	(expand_builtin): Do not allow instrumented calls.

Comments

Jeff Law Oct. 3, 2014, 3:51 p.m. UTC | #1
On 10/03/14 02:47, Ilya Enkovich wrote:
> Since we still don't have a final decision about how instrumented builtin functions would look like, I replace this patch with a new one which assumes we don't instrument them for now.  It only has an additional init for va_start and also makes sure there is no instrumented builtin calls.  All instrumented builtins related codes will go into a separate series.
>
> Thanks,
> Ilya
> --
> 2014-10-03  Ilya Enkovich  <ilya.enkovich@intel.com>
>
> 	* builtins.c: Include tree-chkp.h and rtl-chkp.h.
> 	(std_expand_builtin_va_start): Init bounds for va_list.
> 	(expand_builtin): Do not allow instrumented calls.
OK.  Obviously we'll want to return to the builtins at some point in the 
relatively new future ;-)

jeff
diff mbox

Patch

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 78ac91f..f0bb55a 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -59,6 +59,8 @@  along with GCC; see the file COPYING3.  If not see
 #include "builtins.h"
 #include "ubsan.h"
 #include "cilk.h"
+#include "tree-chkp.h"
+#include "rtl-chkp.h"
 
 
 static tree do_mpc_arg1 (tree, tree, int (*)(mpc_ptr, mpc_srcptr, mpc_rnd_t));
@@ -4319,6 +4321,13 @@  std_expand_builtin_va_start (tree valist, rtx nextarg)
 {
   rtx va_r = expand_expr (valist, NULL_RTX, VOIDmode, EXPAND_WRITE);
   convert_move (va_r, nextarg, 0);
+
+  /* We do not have any valid bounds for the pointer, so
+     just store zero bounds for it.  */
+  if (chkp_function_instrumented_p (current_function_decl))
+    chkp_expand_bounds_reset_for_mem (valist,
+				      make_tree (TREE_TYPE (valist),
+						 nextarg));
 }
 
 /* Expand EXP, a call to __builtin_va_start.  */
@@ -5824,6 +5833,8 @@  expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
 	}
     }
 
+  gcc_assert (!CALL_WITH_BOUNDS_P (exp));
+
   switch (fcode)
     {
     CASE_FLT_FN (BUILT_IN_FABS):
@@ -6841,7 +6852,7 @@  expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
     case BUILT_IN_CHKP_GET_PTR_UBOUND:
       /* We allow user CHKP builtins if Pointer Bounds
 	 Checker is off.  */
-      if (!flag_check_pointer_bounds)
+      if (!chkp_function_instrumented_p (current_function_decl))
 	{
 	  if (fcode == BUILT_IN_CHKP_SET_PTR_BOUNDS
 	      || fcode == BUILT_IN_CHKP_NARROW_PTR_BOUNDS