diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e9b140e069a..2a45134e7d0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-01-26 Michael Matz + + PR tree-optimization/48794 + * tree-eh.c (remove_unreachable_handlers_no_lp): Don't remove + regions referenced from RESX/EH_DISPATCH. + 2012-01-26 Andreas Krebbel * config/s390/s390.h: Make BRANCH_COST an option. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 29df8fcc697..3ff49d77c5e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,7 +1,12 @@ +2012-01-26 Michael Matz + + PR tree-optimization/48794 + * gfortran.dg/gomp/pr48794-2.f90: New testcase. + 2012-01-26 Andreas Krebbel * gcc.dg/ssa-dom-thread-4.c: Set -mbranch-cost=2 for s390 and - s390x. + s390x. 2012-01-26 Andreas Krebbel diff --git a/gcc/testsuite/gfortran.dg/gomp/pr48794-2.f90 b/gcc/testsuite/gfortran.dg/gomp/pr48794-2.f90 new file mode 100644 index 00000000000..b3f9d3c9cf0 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr48794-2.f90 @@ -0,0 +1,16 @@ +! PR tree-optimization/48794 +! { dg-do compile } +! { dg-options "-Os -fopenmp -fexceptions -fno-tree-ccp -fno-tree-copy-prop" } + + integer, allocatable :: a(:) + integer :: b(48) + logical :: l + if (allocated (a)) then + call abort + call bla(b) + end if +!$omp parallel private (a) reduction (.or.:l) + do i = 1, 7 + end do +!$omp end parallel +end diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index cad37e67242..2064d51b952 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -3617,14 +3617,40 @@ remove_unreachable_handlers_no_lp (void) { eh_region r; int i; + sbitmap r_reachable; + basic_block bb; + + r_reachable = sbitmap_alloc (VEC_length (eh_region, cfun->eh->region_array)); + sbitmap_zero (r_reachable); + + FOR_EACH_BB (bb) + { + gimple stmt = last_stmt (bb); + if (stmt) + /* Avoid removing regions referenced from RESX/EH_DISPATCH. */ + switch (gimple_code (stmt)) + { + case GIMPLE_RESX: + SET_BIT (r_reachable, gimple_resx_region (stmt)); + break; + case GIMPLE_EH_DISPATCH: + SET_BIT (r_reachable, gimple_eh_dispatch_region (stmt)); + break; + default: + break; + } + } for (i = 1; VEC_iterate (eh_region, cfun->eh->region_array, i, r); ++i) - if (r && r->landing_pads == NULL && r->type != ERT_MUST_NOT_THROW) + if (r && r->landing_pads == NULL && r->type != ERT_MUST_NOT_THROW + && !TEST_BIT (r_reachable, i)) { if (dump_file) fprintf (dump_file, "Removing unreachable region %d\n", i); remove_eh_handler (r); } + + sbitmap_free (r_reachable); } /* Undo critical edge splitting on an EH landing pad. Earlier, we