This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR63995, CHKP] Use single static bounds var for varpool nodes sharing asm name
- From: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 26 Nov 2014 15:35:45 +0300
- Subject: Re: [PATCH, PR63995, CHKP] Use single static bounds var for varpool nodes sharing asm name
- Authentication-results: sourceware.org; auth=none
- References: <20141125084543 dot GD9490 at msticlxl57 dot ims dot intel dot com> <CAFiYyc14BPU3pwQT_02vvTsOFTHbdZji+AnHhnvWf3+-dEooyg at mail dot gmail dot com> <CAMbmDYZ2=5zXr9KFbQ0GdG=4XF2n6uVrmq_3p=FCGNzNiQSuLw at mail dot gmail dot com> <CAFiYyc1LMgBcPWqJo3KsXbkURGoMrne_KPaFc-hJHC_o7dpoVg at mail dot gmail dot com> <CAMbmDYZi56LQe68XFR17P7zEqna0Ocb65DT0fALy08Hi+TV+7g at mail dot gmail dot com>
On 25 Nov 15:03, Ilya Enkovich wrote:
> 2014-11-25 14:11 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
> > On Tue, Nov 25, 2014 at 11:19 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> >
> > Ok, then it's get_for_asmname (). That said - the above loops look
> > bogus to me. Honza - any better ideas?
>
> get_for_asmname () returns the first element in a chain of nodes with
> the same asm name. May I rely on the order of nodes in this chain?
> Probably use ASSEMBLER_NAME as a key in chkp_static_var_bounds hash?
>
> Thanks,
> Ilya
>
> >
> > Richard.
> >
A variant with var's ASSEMBLER_NAME as a key works fine. Instrumented bootstrap passes. OK for trunk?
Thanks,
Ilya
--
gcc/
2014-11-26 Ilya Enkovich <ilya.enkovich@intel.com>
PR bootstrap/63995
* tree-chkp.c (chkp_make_static_bounds): Share bounds var
between nodes sharing assembler name.
gcc/testsuite
2014-11-26 Ilya Enkovich <ilya.enkovich@intel.com>
PR bootstrap/63995
* g++.dg/dg.exp: Add mpx-dg.exp.
* g++.dg/pr63995-1.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 3e38691..924cb71 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -2727,9 +2727,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. */
@@ -2793,7 +2807,13 @@ chkp_make_static_bounds (tree obj)
if (!chkp_static_var_bounds)
chkp_static_var_bounds = new hash_map<tree, tree>;
- 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;
}
- References:
- [PATCH, PR63995, CHKP] Use single static bounds var for varpool nodes sharing asm name
- Re: [PATCH, PR63995, CHKP] Use single static bounds var for varpool nodes sharing asm name
- Re: [PATCH, PR63995, CHKP] Use single static bounds var for varpool nodes sharing asm name
- Re: [PATCH, PR63995, CHKP] Use single static bounds var for varpool nodes sharing asm name
- Re: [PATCH, PR63995, CHKP] Use single static bounds var for varpool nodes sharing asm name