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.enkov...@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.


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

Reply via email to