On Tue, Nov 25, 2014 at 9:45 AM, Ilya Enkovich <enkovich....@gmail.com> wrote: > Hi, > > This patch partly fixes PR bootstrap/63995 by avoiding duplicating static > bounds vars. With this fix bootstrap still fails at stage 2 and 3 comparison. > > Bootstrapped and checked on x86_64-unknown-linux-gnu. OK for trunk? > > Thanks, > Ilya > -- > gcc/ > > 2014-11-25 Ilya Enkovich <ilya.enkov...@intel.com> > > PR bootstrap/63995 > * tree-chkp (chkp_make_static_bounds): Share bounds var > between nodes sharing assembler name. > > gcc/testsuite > > 2014-11-25 Ilya Enkovich <ilya.enkov...@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..d425084 100644 > --- a/gcc/tree-chkp.c > +++ b/gcc/tree-chkp.c > @@ -2727,9 +2727,29 @@ 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; > + /* If there is a symbol sharing assembler name with obj, > + we may use its bounds. */ > + if (TREE_CODE (obj) == VAR_DECL) > + { > + varpool_node *node = varpool_node::get_create (obj); > + > + while (node->previous_sharing_asm_name) > + node = (varpool_node *)node->previous_sharing_asm_name; > + > + while (node) > + { > + slot = chkp_static_var_bounds->get (node->decl); > + if (slot) > + return *slot; > + node = (varpool_node *)node->next_sharing_asm_name; > + }
Hum. varpool_node::get returns the ultimate alias target thus the walking shouldn't be necessary. Just node = varpool_node::get_create (obj); slot = chkp_static_var_bounds->get (node->decl); if (slot) return *slot; and then making sure to set the decl also for node->decl. I suppose it really asks for making chkp_static_var_bounds->get based on a varpool node and not a decl so you consistently use the ultimate alias target. Richard. > + } > + else > + { > + slot = chkp_static_var_bounds->get (obj); > + if (slot) > + return *slot; > + } > } > > /* Build decl for bounds var. */