As demonstrated by the testcase, the new propagate_constants_for_unrolling can 
change the EH properties of a statement when it turns array accesses with 
variable index into array accesses with fixed index if -fnon-call-exception is 
enabled.

The proposed fix is to call maybe_clean_or_replace_eh_stmt on the modified 
statement.  There is already a call to cleanup_tree_cfg at the end so this 
should be sufficient.

Tested on x86-64/Linux, OK for the mainline?


2012-09-22  Eric Botcazou  <ebotca...@adacore.com>

        PR tree-optimization/54669
        * tree-ssa-loop-ivcanon.c (propagate_into_all_uses): Invoke
        maybe_clean_or_replace_eh_stmt on the modified use statements.


2012-09-22  Eric Botcazou  <ebotca...@adacore.com>

        * gcc.dg/pr54669.c: New test.


-- 
Eric Botcazou
Index: tree-ssa-loop-ivcanon.c
===================================================================
--- tree-ssa-loop-ivcanon.c	(revision 191387)
+++ tree-ssa-loop-ivcanon.c	(working copy)
@@ -531,6 +531,7 @@ propagate_into_all_uses (tree ssa_name,
 
       fold_stmt_inplace (&use_stmt_gsi);
       update_stmt (use_stmt);
+      maybe_clean_or_replace_eh_stmt (use_stmt, use_stmt);
     }
 }
 
/* PR tree-optimization/54669 */
/* Testcase by Zdenek Sojka <zso...@seznam.cz> */

/* { dg-compile } */
/* { dg-options "-O2 -fexceptions -fnon-call-exception" } */

int a[10];

void
foo (void)
{
  int x;
  int i;
  for (i = 0; i < 1;)
    {
      int b[3];
      for (i = 0; i < 1; i++)
	b[i] = a[i];
      if (&x)
	a[0] = b[0];
    }
}

Reply via email to