aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-chkp.c
diff options
context:
space:
mode:
authorIlya Enkovich <ilya.enkovich@intel.com>2014-12-08 10:01:19 +0000
committerIlya Enkovich <ienkovich@gcc.gnu.org>2014-12-08 10:01:19 +0000
commit985f48f7b575747ac5f0ece95816a3bb208fb138 (patch)
treed66ef7fdb2d954f9e839018b44994dd041ffed0c /gcc/tree-chkp.c
parent2625bb5df57f49af1b01e1aef952db551a77824f (diff)
downloadgcc-985f48f7b575747ac5f0ece95816a3bb208fb138.zip
gcc-985f48f7b575747ac5f0ece95816a3bb208fb138.tar.gz
gcc-985f48f7b575747ac5f0ece95816a3bb208fb138.tar.bz2
tree-chkp.c (chkp_call_returns_bounds_p): New.
gcc/ * tree-chkp.c (chkp_call_returns_bounds_p): New. (chkp_build_returned_bound): Use zero bounds as returned by calls not returning bounds. gcc/testsuite/ * gcc.target/i386/chkp-bndret.c: New. * gcc.target/i386/chkp-strchr.c: New. From-SVN: r218478
Diffstat (limited to 'gcc/tree-chkp.c')
-rw-r--r--gcc/tree-chkp.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 56bc303..1ea4f24 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -2082,6 +2082,38 @@ chkp_get_nonpointer_load_bounds (void)
return chkp_get_zero_bounds ();
}
+/* Return 1 if may use bndret call to get bounds for pointer
+ returned by CALL. */
+static bool
+chkp_call_returns_bounds_p (gcall *call)
+{
+ if (gimple_call_internal_p (call))
+ return false;
+
+ tree fndecl = gimple_call_fndecl (call);
+
+ if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
+ return false;
+
+ if (fndecl
+ && lookup_attribute ("bnd_legacy", DECL_ATTRIBUTES (fndecl)))
+ return false;
+
+ if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+ {
+ if (chkp_instrument_normal_builtin (fndecl))
+ return true;
+
+ if (!lookup_attribute ("always_inline", DECL_ATTRIBUTES (fndecl)))
+ return false;
+
+ struct cgraph_node *clone = chkp_maybe_create_clone (fndecl);
+ return (clone && gimple_has_body_p (clone->decl));
+ }
+
+ return true;
+}
+
/* Build bounds returned by CALL. */
static tree
chkp_build_returned_bound (gcall *call)
@@ -2156,7 +2188,7 @@ chkp_build_returned_bound (gcall *call)
bounds = chkp_find_bounds (gimple_call_arg (call, argno), &iter);
}
- else
+ else if (chkp_call_returns_bounds_p (call))
{
gcc_assert (TREE_CODE (gimple_call_lhs (call)) == SSA_NAME);
@@ -2174,6 +2206,8 @@ chkp_build_returned_bound (gcall *call)
update_stmt (stmt);
}
+ else
+ bounds = chkp_get_zero_bounds ();
if (dump_file && (dump_flags & TDF_DETAILS))
{