[PATCH] Fix PR bootstrap/63995

2014-11-26 Thread Ilya Enkovich
Hi,

This patch makes optimization for bounds lifetime reduction to ignore debug 
stetments.  This fixes stage2 and stage3 comparision for instrumented boostrap. 
 OK for trunk?

Thanks,
Ilya
--
2014-11-26  Ilya Enkovich  ilya.enkov...@intel.com

PR bootstrap/63995
* tree-chkp-opt.c (chkp_reduce_bounds_lifetime): Ignore
debug statement when searching for a new position for
bounds load/creation statement.


diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c
index ff390d7..92e0694 100644
--- a/gcc/tree-chkp-opt.c
+++ b/gcc/tree-chkp-opt.c
@@ -1175,6 +1175,9 @@ chkp_reduce_bounds_lifetime (void)
 
   FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, op)
{
+ if (is_gimple_debug (use_stmt))
+   continue;
+
  if (dom_bb 
  dominated_by_p (CDI_DOMINATORS,
  dom_bb, gimple_bb (use_stmt)))


Re: [PATCH] Fix PR bootstrap/63995

2014-11-26 Thread Jakub Jelinek
On Wed, Nov 26, 2014 at 03:41:46PM +0300, Ilya Enkovich wrote:
 Hi,
 
 This patch makes optimization for bounds lifetime reduction to ignore
 debug stetments.  This fixes stage2 and stage3 comparision for
 instrumented boostrap.  OK for trunk?

Please add a small testcase (with -fcompare-debug -fcheck-pointer-bounds (or 
what
other options you need to reproduce it) that fails without the patch and
succeeds with it.

 2014-11-26  Ilya Enkovich  ilya.enkov...@intel.com
 
   PR bootstrap/63995
   * tree-chkp-opt.c (chkp_reduce_bounds_lifetime): Ignore
   debug statement when searching for a new position for
   bounds load/creation statement.
 
 
 diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c
 index ff390d7..92e0694 100644
 --- a/gcc/tree-chkp-opt.c
 +++ b/gcc/tree-chkp-opt.c
 @@ -1175,6 +1175,9 @@ chkp_reduce_bounds_lifetime (void)
  
FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, op)
   {
 +   if (is_gimple_debug (use_stmt))
 + continue;
 +
 if (dom_bb 
 dominated_by_p (CDI_DOMINATORS,
 dom_bb, gimple_bb (use_stmt)))

Jakub


Re: [PATCH] Fix PR bootstrap/63995

2014-11-26 Thread Ilya Enkovich
On 26 Nov 13:46, Jakub Jelinek wrote:
 On Wed, Nov 26, 2014 at 03:41:46PM +0300, Ilya Enkovich wrote:
  Hi,
  
  This patch makes optimization for bounds lifetime reduction to ignore
  debug stetments.  This fixes stage2 and stage3 comparision for
  instrumented boostrap.  OK for trunk?
 
 Please add a small testcase (with -fcompare-debug -fcheck-pointer-bounds (or 
 what
 other options you need to reproduce it) that fails without the patch and
 succeeds with it.
 
  2014-11-26  Ilya Enkovich  ilya.enkov...@intel.com
  
  PR bootstrap/63995
  * tree-chkp-opt.c (chkp_reduce_bounds_lifetime): Ignore
  debug statement when searching for a new position for
  bounds load/creation statement.
  
  
  diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c
  index ff390d7..92e0694 100644
  --- a/gcc/tree-chkp-opt.c
  +++ b/gcc/tree-chkp-opt.c
  @@ -1175,6 +1175,9 @@ chkp_reduce_bounds_lifetime (void)
   
 FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, op)
  {
  + if (is_gimple_debug (use_stmt))
  +   continue;
  +
if (dom_bb 
dominated_by_p (CDI_DOMINATORS,
dom_bb, gimple_bb (use_stmt)))
 
   Jakub

Here is a version with a test added.

Thanks,
Ilya
--
gcc/

2014-11-26  Ilya Enkovich  ilya.enkov...@intel.com

PR bootstrap/63995
* tree-chkp-opt.c (chkp_reduce_bounds_lifetime): Ignore
debug statement when searching for a new position for
bounds load/creation statement.

gcc/testsuite/

2014-11-26  Ilya Enkovich  ilya.enkov...@intel.com

PR bootstrap/63995
* gcc.target/i386/pr63995-2.c: New.


diff --git a/gcc/testsuite/gcc.target/i386/pr63995-2.c 
b/gcc/testsuite/gcc.target/i386/pr63995-2.c
new file mode 100644
index 000..7c22e62
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr63995-2.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target mpx } */
+/* { dg-options -O2 -g -fcheck-pointer-bounds -mmpx -fcompare-debug } */
+
+struct ts
+{
+  int field;
+};
+
+extern void test1 ();
+extern void test2 (struct ts *);
+
+static void
+init (struct ts *c)
+{
+  c-field = -1;
+}
+
+struct ts
+test3 (const struct ts *other)
+{
+  struct ts r;
+  if (other-field != 0)
+test1 ();
+  init (r);
+  test2 (r);
+  return r;
+}
diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c
index ff390d7..92e0694 100644
--- a/gcc/tree-chkp-opt.c
+++ b/gcc/tree-chkp-opt.c
@@ -1175,6 +1175,9 @@ chkp_reduce_bounds_lifetime (void)
 
   FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, op)
{
+ if (is_gimple_debug (use_stmt))
+   continue;
+
  if (dom_bb 
  dominated_by_p (CDI_DOMINATORS,
  dom_bb, gimple_bb (use_stmt)))


Re: [PATCH] Fix PR bootstrap/63995

2014-11-26 Thread Jakub Jelinek
On Wed, Nov 26, 2014 at 04:48:13PM +0300, Ilya Enkovich wrote:
 2014-11-26  Ilya Enkovich  ilya.enkov...@intel.com
 
   PR bootstrap/63995
   * tree-chkp-opt.c (chkp_reduce_bounds_lifetime): Ignore
   debug statement when searching for a new position for
   bounds load/creation statement.
 
 gcc/testsuite/
 
 2014-11-26  Ilya Enkovich  ilya.enkov...@intel.com
 
   PR bootstrap/63995
   * gcc.target/i386/pr63995-2.c: New.

Ok, thanks.

Jakub