tree-chkp.c (chkp_find_const_bounds_var): Remove.
gcc/ * tree-chkp.c (chkp_find_const_bounds_var): Remove. (chkp_make_static_const_bounds): Search existing symbol by assembler name. Use make_decl_one_only. (chkp_get_zero_bounds_var): Remove node search which is now performed in chkp_make_static_const_bounds. (chkp_get_none_bounds_var): Likewise. gcc/testsuite/ * gcc.dg/lto/chkp-static-bounds_0.c: New. From-SVN: r221932
This commit is contained in:
parent
469f062eb9
commit
36f371de39
4 changed files with 62 additions and 60 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2015-04-08 Ilya Enkovich <ilya.enkovich@intel.com>
|
||||||
|
|
||||||
|
* tree-chkp.c (chkp_find_const_bounds_var): Remove.
|
||||||
|
(chkp_make_static_const_bounds): Search existing
|
||||||
|
symbol by assembler name. Use make_decl_one_only.
|
||||||
|
(chkp_get_zero_bounds_var): Remove node search which
|
||||||
|
is now performed in chkp_make_static_const_bounds.
|
||||||
|
(chkp_get_none_bounds_var): Likewise.
|
||||||
|
|
||||||
2015-04-08 Michael Witten <mfwitten@gmail.com>
|
2015-04-08 Michael Witten <mfwitten@gmail.com>
|
||||||
|
|
||||||
* doc/extend.texi (Attribute Syntax): Add a trailing semicolon
|
* doc/extend.texi (Attribute Syntax): Add a trailing semicolon
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2015-04-08 Ilya Enkovich <ilya.enkovich@intel.com>
|
||||||
|
|
||||||
|
* gcc.dg/lto/chkp-static-bounds_0.c: New.
|
||||||
|
|
||||||
2015-04-08 Ilya Enkovich <ilya.enkovich@intel.com>
|
2015-04-08 Ilya Enkovich <ilya.enkovich@intel.com>
|
||||||
|
|
||||||
* gcc.target/i386/mpx/chkp-thunk-comdat-3.c: New.
|
* gcc.target/i386/mpx/chkp-thunk-comdat-3.c: New.
|
||||||
|
|
26
gcc/testsuite/gcc.dg/lto/chkp-static-bounds_0.c
Normal file
26
gcc/testsuite/gcc.dg/lto/chkp-static-bounds_0.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/* { dg-lto-do link } */
|
||||||
|
/* { dg-require-effective-target mpx } */
|
||||||
|
/* { dg-lto-options { { -flto -flto-partition=max -fcheck-pointer-bounds -mmpx } } } */
|
||||||
|
|
||||||
|
const char *cc;
|
||||||
|
|
||||||
|
int test1 (const char *c)
|
||||||
|
{
|
||||||
|
c = __builtin___bnd_init_ptr_bounds (c);
|
||||||
|
cc = c;
|
||||||
|
return c[0] * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
int (*fnptr) (const char *);
|
||||||
|
} S;
|
||||||
|
|
||||||
|
struct S s1 = {test1};
|
||||||
|
struct S s2 = {test1};
|
||||||
|
struct S s3 = {test1};
|
||||||
|
|
||||||
|
int main (int argc, const char **argv)
|
||||||
|
{
|
||||||
|
return s1.fnptr (argv[0]) + s2.fnptr (argv[1]);
|
||||||
|
}
|
|
@ -1902,33 +1902,6 @@ chkp_add_bounds_to_call_stmt (gimple_stmt_iterator *gsi)
|
||||||
gimple_call_set_with_bounds (new_call, true);
|
gimple_call_set_with_bounds (new_call, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return constant static bounds var with specified LB and UB
|
|
||||||
if such var exists in varpool. Return NULL otherwise. */
|
|
||||||
static tree
|
|
||||||
chkp_find_const_bounds_var (HOST_WIDE_INT lb,
|
|
||||||
HOST_WIDE_INT ub)
|
|
||||||
{
|
|
||||||
tree val = targetm.chkp_make_bounds_constant (lb, ub);
|
|
||||||
struct varpool_node *node;
|
|
||||||
|
|
||||||
/* We expect bounds constant is represented as a complex value
|
|
||||||
of two pointer sized integers. */
|
|
||||||
gcc_assert (TREE_CODE (val) == COMPLEX_CST);
|
|
||||||
|
|
||||||
FOR_EACH_VARIABLE (node)
|
|
||||||
if (POINTER_BOUNDS_P (node->decl)
|
|
||||||
&& TREE_READONLY (node->decl)
|
|
||||||
&& DECL_INITIAL (node->decl)
|
|
||||||
&& TREE_CODE (DECL_INITIAL (node->decl)) == COMPLEX_CST
|
|
||||||
&& tree_int_cst_equal (TREE_REALPART (DECL_INITIAL (node->decl)),
|
|
||||||
TREE_REALPART (val))
|
|
||||||
&& tree_int_cst_equal (TREE_IMAGPART (DECL_INITIAL (node->decl)),
|
|
||||||
TREE_IMAGPART (val)))
|
|
||||||
return node->decl;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return constant static bounds var with specified bounds LB and UB.
|
/* Return constant static bounds var with specified bounds LB and UB.
|
||||||
If such var does not exists then new var is created with specified NAME. */
|
If such var does not exists then new var is created with specified NAME. */
|
||||||
static tree
|
static tree
|
||||||
|
@ -1936,37 +1909,43 @@ chkp_make_static_const_bounds (HOST_WIDE_INT lb,
|
||||||
HOST_WIDE_INT ub,
|
HOST_WIDE_INT ub,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
|
tree id = get_identifier (name);
|
||||||
tree var;
|
tree var;
|
||||||
|
varpool_node *node;
|
||||||
|
symtab_node *snode;
|
||||||
|
|
||||||
|
var = build_decl (UNKNOWN_LOCATION, VAR_DECL, id,
|
||||||
|
pointer_bounds_type_node);
|
||||||
|
TREE_STATIC (var) = 1;
|
||||||
|
TREE_PUBLIC (var) = 1;
|
||||||
|
|
||||||
/* With LTO we may have constant bounds already in varpool.
|
/* With LTO we may have constant bounds already in varpool.
|
||||||
Try to find it. */
|
Try to find it. */
|
||||||
var = chkp_find_const_bounds_var (lb, ub);
|
if ((snode = symtab_node::get_for_asmname (DECL_ASSEMBLER_NAME (var))))
|
||||||
|
{
|
||||||
|
/* We don't allow this symbol usage for non bounds. */
|
||||||
|
if (snode->type != SYMTAB_VARIABLE
|
||||||
|
|| !POINTER_BOUNDS_P (snode->decl))
|
||||||
|
sorry ("-fcheck-pointer-bounds requires '%s' "
|
||||||
|
"name for internal usage",
|
||||||
|
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (var)));
|
||||||
|
|
||||||
if (var)
|
return snode->decl;
|
||||||
return var;
|
}
|
||||||
|
|
||||||
var = build_decl (UNKNOWN_LOCATION, VAR_DECL,
|
|
||||||
get_identifier (name), pointer_bounds_type_node);
|
|
||||||
|
|
||||||
TREE_PUBLIC (var) = 1;
|
|
||||||
TREE_USED (var) = 1;
|
TREE_USED (var) = 1;
|
||||||
TREE_READONLY (var) = 1;
|
TREE_READONLY (var) = 1;
|
||||||
TREE_STATIC (var) = 1;
|
|
||||||
TREE_ADDRESSABLE (var) = 0;
|
TREE_ADDRESSABLE (var) = 0;
|
||||||
DECL_ARTIFICIAL (var) = 1;
|
DECL_ARTIFICIAL (var) = 1;
|
||||||
DECL_READ_P (var) = 1;
|
DECL_READ_P (var) = 1;
|
||||||
|
DECL_INITIAL (var) = targetm.chkp_make_bounds_constant (lb, ub);
|
||||||
|
make_decl_one_only (var, DECL_ASSEMBLER_NAME (var));
|
||||||
/* We may use this symbol during ctors generation in chkp_finish_file
|
/* We may use this symbol during ctors generation in chkp_finish_file
|
||||||
when all symbols are emitted. Force output to avoid undefined
|
when all symbols are emitted. Force output to avoid undefined
|
||||||
symbols in ctors. */
|
symbols in ctors. */
|
||||||
if (!in_lto_p)
|
node = varpool_node::get_create (var);
|
||||||
{
|
node->force_output = 1;
|
||||||
DECL_INITIAL (var) = targetm.chkp_make_bounds_constant (lb, ub);
|
|
||||||
DECL_COMDAT (var) = 1;
|
|
||||||
varpool_node::get_create (var)->set_comdat_group (DECL_ASSEMBLER_NAME (var));
|
|
||||||
varpool_node::get_create (var)->force_output = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
DECL_EXTERNAL (var) = 1;
|
|
||||||
varpool_node::finalize_decl (var);
|
varpool_node::finalize_decl (var);
|
||||||
|
|
||||||
return var;
|
return var;
|
||||||
|
@ -2029,14 +2008,6 @@ chkp_make_bounds (tree lb, tree size, gimple_stmt_iterator *iter, bool after)
|
||||||
tree
|
tree
|
||||||
chkp_get_zero_bounds_var (void)
|
chkp_get_zero_bounds_var (void)
|
||||||
{
|
{
|
||||||
if (!chkp_zero_bounds_var)
|
|
||||||
{
|
|
||||||
tree id = get_identifier (CHKP_ZERO_BOUNDS_VAR_NAME);
|
|
||||||
symtab_node *node = symtab_node::get_for_asmname (id);
|
|
||||||
if (node)
|
|
||||||
chkp_zero_bounds_var = node->decl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!chkp_zero_bounds_var)
|
if (!chkp_zero_bounds_var)
|
||||||
chkp_zero_bounds_var
|
chkp_zero_bounds_var
|
||||||
= chkp_make_static_const_bounds (0, -1,
|
= chkp_make_static_const_bounds (0, -1,
|
||||||
|
@ -2048,14 +2019,6 @@ chkp_get_zero_bounds_var (void)
|
||||||
tree
|
tree
|
||||||
chkp_get_none_bounds_var (void)
|
chkp_get_none_bounds_var (void)
|
||||||
{
|
{
|
||||||
if (!chkp_none_bounds_var)
|
|
||||||
{
|
|
||||||
tree id = get_identifier (CHKP_NONE_BOUNDS_VAR_NAME);
|
|
||||||
symtab_node *node = symtab_node::get_for_asmname (id);
|
|
||||||
if (node)
|
|
||||||
chkp_none_bounds_var = node->decl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!chkp_none_bounds_var)
|
if (!chkp_none_bounds_var)
|
||||||
chkp_none_bounds_var
|
chkp_none_bounds_var
|
||||||
= chkp_make_static_const_bounds (-1, 0,
|
= chkp_make_static_const_bounds (-1, 0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue