]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
builtin-types.def (BT_FN_PTR_CONST_PTR_VAR): New.
authorIlya Enkovich <ilya.enkovich@intel.com>
Mon, 18 Nov 2013 12:30:52 +0000 (12:30 +0000)
committerKirill Yukhin <kyukhin@gcc.gnu.org>
Mon, 18 Nov 2013 12:30:52 +0000 (12:30 +0000)
        * builtin-types.def (BT_FN_PTR_CONST_PTR_VAR): New.
        * chkp-builtins.def (BUILT_IN_CHKP_BIND_BOUNDS): New.
        * cfgexpand.c (expand_call_stmt): Expand BUILT_IN_CHKP_BIND_BOUNDS.
        * gimple.c (gimple_call_get_nobnd_arg_index): Remove.
        * gimple.h (gf_mask): Add GF_CALL_WITH_BOUNDS.
        (gimple_call_with_bounds_p): New.
        (gimple_call_set_with_bounds): New.
        (gimple_call_num_nobnd_args): Remove.
        (gimple_call_nobnd_arg): Remove.
        * tree.h (CALL_WITH_BOUNDS_P): New.
        * rtl.h (CALL_EXPR_WITH_BOUNDS_P): New.

From-SVN: r204947

gcc/ChangeLog
gcc/builtin-types.def
gcc/cfgexpand.c
gcc/chkp-builtins.def
gcc/gimple.c
gcc/gimple.h
gcc/rtl.h
gcc/tree.h

index 8bb1a441535a4179e35f3e53e841c0f2fcb22e72..72e707a6ed5106c8375064a65145a0e404d57bb5 100644 (file)
@@ -1,3 +1,17 @@
+2013-11-18  Ilya Enkovich  <ilya.enkovich@intel.com>
+
+       * builtin-types.def (BT_FN_PTR_CONST_PTR_VAR): New.
+       * chkp-builtins.def (BUILT_IN_CHKP_BIND_BOUNDS): New.
+       * cfgexpand.c (expand_call_stmt): Expand BUILT_IN_CHKP_BIND_BOUNDS.
+       * gimple.c (gimple_call_get_nobnd_arg_index): Remove.
+       * gimple.h (gf_mask): Add GF_CALL_WITH_BOUNDS.
+       (gimple_call_with_bounds_p): New.
+       (gimple_call_set_with_bounds): New.
+       (gimple_call_num_nobnd_args): Remove.
+       (gimple_call_nobnd_arg): Remove.
+       * tree.h (CALL_WITH_BOUNDS_P): New.
+       * rtl.h (CALL_EXPR_WITH_BOUNDS_P): New.
+
 2013-11-18  Trevor Saunders  <tsaunders@mozilla.com>
 
        * cgraph.h (symtab_node_asm_name): Rename to symtab_node::asm_name.
index 1f9ae4e2317550f089f61888d448dfe7091f58c7..e7bfaf943d40d55244a10d5a9748d65d672c1db2 100644 (file)
@@ -542,6 +542,8 @@ DEF_FUNCTION_TYPE_VAR_1 (BT_FN_INT_CONST_STRING_VAR,
                         BT_INT, BT_CONST_STRING)
 DEF_FUNCTION_TYPE_VAR_1 (BT_FN_UINT32_UINT32_VAR,
                         BT_UINT32, BT_UINT32)
+DEF_FUNCTION_TYPE_VAR_1 (BT_FN_PTR_CONST_PTR_VAR,
+                        BT_PTR, BT_CONST_PTR)
 
 DEF_FUNCTION_TYPE_VAR_2 (BT_FN_INT_FILEPTR_CONST_STRING_VAR,
                         BT_INT, BT_FILEPTR, BT_CONST_STRING)
index 3100688d72e2093297944ba3ed8b7a42578b01b9..124a4b89dfba4b56dc38060d51f046aab03f499b 100644 (file)
@@ -2154,12 +2154,22 @@ expand_call_stmt (gimple stmt)
       return;
     }
 
-  exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
-
-  CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
   decl = gimple_call_fndecl (stmt);
   builtin_p = decl && DECL_BUILT_IN (decl);
 
+  /* Bind bounds call is expanded as assignment.  */
+  if (builtin_p
+      && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
+      && DECL_FUNCTION_CODE (decl) == BUILT_IN_CHKP_BIND_BOUNDS)
+    {
+      expand_assignment (gimple_call_lhs (stmt),
+                        gimple_call_arg (stmt, 0), false);
+      return;
+    }
+
+  exp = build_vl_exp (CALL_EXPR, gimple_call_num_args (stmt) + 3);
+  CALL_EXPR_FN (exp) = gimple_call_fn (stmt);
+
   /* If this is not a builtin function, the function type through which the
      call is made may be different from the type of the function.  */
   if (!builtin_p)
index d19b5418a367fa0829d0700567743e346f1d0f61..b920950d603935a013f0fb5c024a21299689dc31 100644 (file)
@@ -42,6 +42,9 @@ DEF_BUILTIN_STUB (BUILT_IN_CHKP_EXTRACT_LOWER, "__chkp_extract_lower")
 DEF_BUILTIN_STUB (BUILT_IN_CHKP_EXTRACT_UPPER, "__chkp_extract_upper")
 DEF_BUILTIN_STUB (BUILT_IN_CHKP_NARROW, "__chkp_narrow")
 
+/* Builtins to bind bounds to call arguments.  */
+DEF_CHKP_BUILTIN (BUILT_IN_CHKP_BIND_BOUNDS, "__chkp_bind_bounds", BT_FN_PTR_CONST_PTR_VAR, ATTR_CONST_NOTHROW_LEAF_LIST)
+
 /* Pointer Bounds Checker builtins for users.  Only
    BUILT_IN_CHKP_SET_PTR_BOUNDS may be redefined
    by target.  Other builtins calls are expanded
index f42d921fa0f3f424309f3dcd7927c459af2faded..2d642616ae331e9eea4b4ad7728fe15c652da6e1 100644 (file)
@@ -365,26 +365,6 @@ gimple_build_call_from_tree (tree t)
 }
 
 
-/* Return index of INDEX's non bound argument of the call.  */
-
-unsigned
-gimple_call_get_nobnd_arg_index (const_gimple gs, unsigned index)
-{
-  unsigned num_args = gimple_call_num_args (gs);
-  for (unsigned n = 0; n < num_args; n++)
-    {
-      if (POINTER_BOUNDS_P (gimple_call_arg (gs, n)))
-       continue;
-      else if (index)
-       index--;
-      else
-       return n;
-    }
-
-  gcc_unreachable ();
-}
-
-
 /* Build a GIMPLE_ASSIGN statement.
 
    LHS of the assignment.
index 022bac93aaf290cd9106514658069509e1c34da9..4234c3cfdb497c80753a0aa8d6246520aa362efc 100644 (file)
@@ -101,6 +101,7 @@ enum gf_mask {
     GF_CALL_NOTHROW            = 1 << 4,
     GF_CALL_ALLOCA_FOR_VAR     = 1 << 5,
     GF_CALL_INTERNAL           = 1 << 6,
+    GF_CALL_WITH_BOUNDS        = 1 << 7,
     GF_OMP_PARALLEL_COMBINED   = 1 << 0,
     GF_OMP_FOR_KIND_MASK       = 3 << 0,
     GF_OMP_FOR_KIND_FOR                = 0 << 0,
@@ -737,7 +738,6 @@ gimple gimple_build_call_valist (tree, unsigned, va_list);
 gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
 gimple gimple_build_call_internal_vec (enum internal_fn, vec<tree> );
 gimple gimple_build_call_from_tree (tree);
-extern unsigned gimple_call_get_nobnd_arg_index (const_gimple, unsigned);
 gimple gimple_build_assign_stat (tree, tree MEM_STAT_DECL);
 #define gimple_build_assign(l,r) gimple_build_assign_stat (l, r MEM_STAT_INFO)
 gimple gimple_build_assign_with_ops (enum tree_code, tree,
@@ -1960,6 +1960,31 @@ gimple_call_internal_p (const_gimple gs)
 }
 
 
+/* Return true if call GS is marked as instrumented by
+   Pointer Bounds Checker.  */
+
+static inline bool
+gimple_call_with_bounds_p (const_gimple gs)
+{
+  GIMPLE_CHECK (gs, GIMPLE_CALL);
+  return (gs->gsbase.subcode & GF_CALL_WITH_BOUNDS) != 0;
+}
+
+
+/* If INSTRUMENTED_P is true, marm statement GS as instrumented by
+   Pointer Bounds Checker.  */
+
+static inline void
+gimple_call_set_with_bounds (gimple gs, bool with_bounds)
+{
+  GIMPLE_CHECK (gs, GIMPLE_CALL);
+  if (with_bounds)
+    gs->gsbase.subcode |= GF_CALL_WITH_BOUNDS;
+  else
+    gs->gsbase.subcode &= ~GF_CALL_WITH_BOUNDS;
+}
+
+
 /* Return the target of internal call GS.  */
 
 static inline enum internal_fn
@@ -2125,32 +2150,6 @@ gimple_call_arg (const_gimple gs, unsigned index)
 }
 
 
-/* Return the number of arguments used by call statement GS
-   ignoring bound ones.  */
-
-static inline unsigned
-gimple_call_num_nobnd_args (const_gimple gs)
-{
-  unsigned num_args = gimple_call_num_args (gs);
-  unsigned res = num_args;
-  for (unsigned n = 0; n < num_args; n++)
-    if (POINTER_BOUNDS_P (gimple_call_arg (gs, n)))
-      res--;
-  return res;
-}
-
-
-/* Return INDEX's call argument ignoring bound ones.  */
-static inline tree
-gimple_call_nobnd_arg (const_gimple gs, unsigned index)
-{
-  /* No bound args may exist if pointers checker is off.  */
-  if (!flag_check_pointer_bounds)
-    return gimple_call_arg (gs, index);
-  return gimple_call_arg (gs, gimple_call_get_nobnd_arg_index (gs, index));
-}
-
-
 /* Return a pointer to the argument at position INDEX for call
    statement GS.  */
 
index 247a0d0670183a3a7d57f9968fc78b7e0f4a1bc3..bab5b7c75377bf6db50ab68077db90c70e5c19e3 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -266,7 +266,8 @@ struct GTY((chain_next ("RTX_NEXT (&%h)"),
      In a CODE_LABEL, part of the two-bit alternate entry field.
      1 in a CONCAT is VAL_EXPR_IS_COPIED in var-tracking.c.
      1 in a VALUE is SP_BASED_VALUE_P in cselib.c.
-     1 in a SUBREG generated by LRA for reload insns.  */
+     1 in a SUBREG generated by LRA for reload insns.
+     1 in a CALL for calls instrumented by Pointer Bounds Checker.  */
   unsigned int jump : 1;
   /* In a CODE_LABEL, part of the two-bit alternate entry field.
      1 in a MEM if it cannot trap.
@@ -1420,6 +1421,10 @@ do {                                                                     \
 #define LRA_SUBREG_P(RTX)      \
   (RTL_FLAG_CHECK1 ("LRA_SUBREG_P", (RTX), SUBREG)->jump)
 
+/* True if call is instrumented by Pointer Bounds Checker.  */
+#define CALL_EXPR_WITH_BOUNDS_P(RTX) \
+  (RTL_FLAG_CHECK1 ("CALL_EXPR_WITH_BOUNDS_P", (RTX), CALL)->jump)
+
 /* Access various components of an ASM_OPERANDS rtx.  */
 
 #define ASM_OPERANDS_TEMPLATE(RTX) XCSTR (RTX, 0, ASM_OPERANDS)
index bc6699dca98a6a214b7adbddad83e8fbde3be601..dee15be7321db25537cfce39092f97428d43c4ff 100644 (file)
@@ -831,6 +831,9 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
 #define CALL_ALLOCA_FOR_VAR_P(NODE) \
   (CALL_EXPR_CHECK (NODE)->base.protected_flag)
 
+/* In a CALL_EXPR, means call was instrumented by Pointer Bounds Checker.  */
+#define CALL_WITH_BOUNDS_P(NODE) (CALL_EXPR_CHECK (NODE)->base.deprecated_flag)
+
 /* In a type, nonzero means that all objects of the type are guaranteed by the
    language or front-end to be properly aligned, so we can indicate that a MEM
    of this type is aligned at least to the alignment of the type, even if it