From 227eabce47178c49601a13b801cca57d41494b8f Mon Sep 17 00:00:00 2001 From: Ilya Enkovich Date: Tue, 9 Dec 2014 07:53:17 +0000 Subject: re PR bootstrap/63995 (Bootstrap error with -mmpx -fcheck-pointer-bounds) gcc/ PR bootstrap/63995 * tree-chkp.c (chkp_make_static_bounds): Share bounds var between nodes sharing assembler name. gcc/testsuite/ PR bootstrap/63995 * g++.dg/dg.exp: Add mpx-dg.exp. * g++.dg/pr63995-1.C: New. From-SVN: r218506 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/dg.exp | 1 + gcc/testsuite/g++.dg/pr63995-1.C | 16 ++++++++++++++++ gcc/tree-chkp.c | 28 ++++++++++++++++++++++++---- 5 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr63995-1.C (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5217b8d57..dbd6272 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-12-09 Ilya Enkovich + + PR bootstrap/63995 + * tree-chkp.c (chkp_make_static_bounds): Share bounds var + between nodes sharing assembler name. + 2014-12-08 Michael Meissner PR target/64204 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b5ddcca..1b1e7d5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-12-09 Ilya Enkovich + + PR bootstrap/63995 + * g++.dg/dg.exp: Add mpx-dg.exp. + * g++.dg/pr63995-1.C: New. + 2014-12-08 Sandra Loosemore * gcc.target/aarch64/bics_4.c: New. diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp index 14beae1..44eab0c 100644 --- a/gcc/testsuite/g++.dg/dg.exp +++ b/gcc/testsuite/g++.dg/dg.exp @@ -18,6 +18,7 @@ # Load support procs. load_lib g++-dg.exp +load_lib mpx-dg.exp # If a testcase doesn't have special options, use these. global DEFAULT_CXXFLAGS diff --git a/gcc/testsuite/g++.dg/pr63995-1.C b/gcc/testsuite/g++.dg/pr63995-1.C new file mode 100644 index 0000000..82e7606 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr63995-1.C @@ -0,0 +1,16 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options "-O2 -g -fcheck-pointer-bounds -mmpx" } */ + +int test1 (int i) +{ + extern const int arr[10]; + return arr[i]; +} + +extern const int arr[10]; + +int test2 (int i) +{ + return arr[i]; +} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index c24aa35..e7b9bbf 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -2760,9 +2760,23 @@ chkp_make_static_bounds (tree obj) /* First check if we already have required var. */ if (chkp_static_var_bounds) { - slot = chkp_static_var_bounds->get (obj); - if (slot) - return *slot; + /* For vars we use assembler name as a key in + chkp_static_var_bounds map. It allows to + avoid duplicating bound vars for decls + sharing assembler name. */ + if (TREE_CODE (obj) == VAR_DECL) + { + tree name = DECL_ASSEMBLER_NAME (obj); + slot = chkp_static_var_bounds->get (name); + if (slot) + return *slot; + } + else + { + slot = chkp_static_var_bounds->get (obj); + if (slot) + return *slot; + } } /* Build decl for bounds var. */ @@ -2826,7 +2840,13 @@ chkp_make_static_bounds (tree obj) if (!chkp_static_var_bounds) chkp_static_var_bounds = new hash_map; - chkp_static_var_bounds->put (obj, bnd_var); + if (TREE_CODE (obj) == VAR_DECL) + { + tree name = DECL_ASSEMBLER_NAME (obj); + chkp_static_var_bounds->put (name, bnd_var); + } + else + chkp_static_var_bounds->put (obj, bnd_var); return bnd_var; } -- cgit v1.1