* 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
+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.
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)
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)
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
}
-/* 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.
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,
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,
}
+/* 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
}
-/* 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. */
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.
#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)
#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