diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-04-15 00:24:59 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2006-04-15 00:24:59 +0200 |
commit | 7e2df4a192476c23624aa62799844224b6b53938 (patch) | |
tree | 1cf0a8f2ef66b04878785ffcb60ed3de58e0a0b7 /gcc | |
parent | 008712ae1cf581c664f18f44ccac6d36ccbf3b93 (diff) | |
download | gcc-7e2df4a192476c23624aa62799844224b6b53938.zip gcc-7e2df4a192476c23624aa62799844224b6b53938.tar.gz gcc-7e2df4a192476c23624aa62799844224b6b53938.tar.bz2 |
re PR middle-end/26823 (ICE with OpenMP in add_stmt_to_eh_region_fn, at tree-eh.c:100)
PR middle-end/26823
* except.h (eh_region_outermost): New prototype.
* except.c (eh_region_outermost): New function.
* tree-cfg.c (find_outermost_region_in_block): Use it.
* g++.dg/gomp/pr26823-1.C: New test.
* g++.dg/gomp/pr26823-2.C: New test.
From-SVN: r112959
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/except.c | 42 | ||||
-rw-r--r-- | gcc/except.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/gomp/pr26823-1.C | 23 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/gomp/pr26823-2.C | 29 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 105 |
7 files changed, 158 insertions, 55 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c9cfac4..6079a41 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2006-04-15 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/26823 + * except.h (eh_region_outermost): New prototype. + * except.c (eh_region_outermost): New function. + * tree-cfg.c (find_outermost_region_in_block): Use it. + 2006-04-14 Kazu Hirata <kazu@codesourcery.com> * local-alloc.c (rest_of_handle_local_alloc): Use VEC instead diff --git a/gcc/except.c b/gcc/except.c index 3feda0f..57e71bd 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -1078,6 +1078,48 @@ eh_region_outer_p (struct function *ifun, int region_a, int region_b) return false; } + +/* Return region number of region that is outer to both if REGION_A and + REGION_B in IFUN. */ + +int +eh_region_outermost (struct function *ifun, int region_a, int region_b) +{ + struct eh_region *rp_a, *rp_b; + sbitmap b_outer; + + gcc_assert (ifun->eh->last_region_number > 0); + gcc_assert (ifun->eh->region_tree); + + rp_a = VEC_index (eh_region, ifun->eh->region_array, region_a); + rp_b = VEC_index (eh_region, ifun->eh->region_array, region_b); + gcc_assert (rp_a != NULL); + gcc_assert (rp_b != NULL); + + b_outer = sbitmap_alloc (ifun->eh->last_region_number + 1); + sbitmap_zero (b_outer); + + do + { + SET_BIT (b_outer, rp_b->region_number); + rp_b = rp_b->outer; + } + while (rp_b); + + do + { + if (TEST_BIT (b_outer, rp_a->region_number)) + { + sbitmap_free (b_outer); + return rp_a->region_number; + } + rp_a = rp_a->outer; + } + while (rp_a); + + sbitmap_free (b_outer); + return -1; +} static int t2r_eq (const void *pentry, const void *pdata) diff --git a/gcc/except.h b/gcc/except.h index 5b28296..1f96477 100644 --- a/gcc/except.h +++ b/gcc/except.h @@ -108,6 +108,7 @@ extern void expand_resx_expr (tree); extern void verify_eh_tree (struct function *); extern void dump_eh_tree (FILE *, struct function *); extern bool eh_region_outer_p (struct function *, int, int); +extern int eh_region_outermost (struct function *, int, int); /* tree-eh.c */ extern void add_stmt_to_eh_region_fn (struct function *, tree, int); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b19e82f..28eeeb6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-04-15 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/26823 + * g++.dg/gomp/pr26823-1.C: New test. + * g++.dg/gomp/pr26823-2.C: New test. + 2006-04-13 Uros Bizjak <uros@kss-loka.si> PR middle-end/27134 diff --git a/gcc/testsuite/g++.dg/gomp/pr26823-1.C b/gcc/testsuite/g++.dg/gomp/pr26823-1.C new file mode 100644 index 0000000..d24eddb --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26823-1.C @@ -0,0 +1,23 @@ +// PR middle-end/26823 +// { dg-do compile } + +struct A +{ + ~A () {} +}; + +struct B +{ + A a; + B (); +}; + +void +foo () +{ +#pragma omp parallel + { + B b[1]; + new int; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/pr26823-2.C b/gcc/testsuite/g++.dg/gomp/pr26823-2.C new file mode 100644 index 0000000..d4747cf --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr26823-2.C @@ -0,0 +1,29 @@ +// PR middle-end/26823 +// { dg-do compile } + +struct A +{ + ~A () {} +}; + +extern void bar (); + +void +foo () +{ +#pragma omp parallel + { + { + A a; + bar (); + } + { + A a; + bar (); + } + { + A a; + bar (); + } + } +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 7fa936e..f6a44ba 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -103,6 +103,7 @@ static void make_edges (void); static void make_cond_expr_edges (basic_block); static void make_switch_expr_edges (basic_block); static void make_goto_expr_edges (basic_block); +static void make_omp_sections_edges (basic_block); static edge tree_redirect_edge_and_branch (edge, basic_block); static edge tree_try_redirect_by_replacing_jump (edge, basic_block); static unsigned int split_critical_edges (void); @@ -446,7 +447,6 @@ static void make_edges (void) { basic_block bb; - struct omp_region *cur_region = NULL; /* Create an edge from entry to the first block with executable statements in it. */ @@ -460,8 +460,7 @@ make_edges (void) if (last) { - enum tree_code code = TREE_CODE (last); - switch (code) + switch (TREE_CODE (last)) { case GOTO_EXPR: make_goto_expr_edges (bb); @@ -523,53 +522,18 @@ make_edges (void) case OMP_ORDERED: case OMP_CRITICAL: case OMP_SECTION: - cur_region = new_omp_region (bb, code, cur_region); fallthru = true; break; - case OMP_SECTIONS: - cur_region = new_omp_region (bb, code, cur_region); - fallthru = false; - break; - - case OMP_RETURN: - /* In the case of an OMP_SECTION, the edge will go somewhere - other than the next block. This will be created later. */ - cur_region->exit = bb; - fallthru = cur_region->type != OMP_SECTION; - cur_region = cur_region->outer; + case OMP_RETURN_EXPR: + /* In the case of an OMP_SECTION, we may have already made + an edge in make_omp_sections_edges. */ + fallthru = EDGE_COUNT (bb->succs) == 0; break; - case OMP_CONTINUE: - cur_region->cont = bb; - switch (cur_region->type) - { - case OMP_FOR: - /* ??? Technically there should be a some sort of loopback - edge here, but it goes to a block that doesn't exist yet, - and without it, updating the ssa form would be a real - bear. Fortunately, we don't yet do ssa before expanding - these nodes. */ - break; - - case OMP_SECTIONS: - /* Wire up the edges into and out of the nested sections. */ - /* ??? Similarly wrt loopback. */ - { - struct omp_region *i; - for (i = cur_region->inner; i ; i = i->next) - { - gcc_assert (i->type == OMP_SECTION); - make_edge (cur_region->entry, i->entry, 0); - make_edge (i->exit, bb, EDGE_FALLTHRU); - } - } - break; - - default: - gcc_unreachable (); - } - fallthru = true; + case OMP_SECTIONS: + make_omp_sections_edges (bb); + fallthru = false; break; default: @@ -584,9 +548,6 @@ make_edges (void) make_edge (bb, bb->next_bb, EDGE_FALLTHRU); } - if (root_omp_region) - free_omp_regions (); - /* Fold COND_EXPR_COND of each COND_EXPR. */ fold_cond_expr_cond (); @@ -595,6 +556,35 @@ make_edges (void) } +/* Link an OMP_SECTIONS block to all the OMP_SECTION blocks in its body. */ + +static void +make_omp_sections_edges (basic_block bb) +{ + basic_block exit_bb; + size_t i, n; + tree vec, stmt; + + stmt = last_stmt (bb); + vec = OMP_SECTIONS_SECTIONS (stmt); + n = TREE_VEC_LENGTH (vec); + exit_bb = bb_for_stmt (TREE_VEC_ELT (vec, n - 1)); + + for (i = 0; i < n - 1; i += 2) + { + basic_block start_bb = bb_for_stmt (TREE_VEC_ELT (vec, i)); + basic_block end_bb = bb_for_stmt (TREE_VEC_ELT (vec, i + 1)); + make_edge (bb, start_bb, 0); + make_edge (end_bb, exit_bb, EDGE_FALLTHRU); + } + + /* Once the CFG has been built, the vector of sections is no longer + useful. The region can be easily obtained with build_omp_regions. + Furthermore, this sharing of tree expressions is not allowed by the + statement verifier. */ + OMP_SECTIONS_SECTIONS (stmt) = NULL_TREE; +} + /* Create the edges for a COND_EXPR starting at block BB. At this point, both clauses must contain only simple gotos. */ @@ -2508,7 +2498,7 @@ is_ctrl_altering_stmt (tree t) } /* OpenMP directives alter control flow. */ - if (OMP_DIRECTIVE_P (t)) + if (flag_openmp && OMP_DIRECTIVE_P (t)) return true; /* If a statement can throw, it alters control flow. */ @@ -4559,9 +4549,7 @@ move_stmt_r (tree *tp, int *walk_subtrees, void *data) if (p->block && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (t)))) TREE_BLOCK (t) = p->block; - if (OMP_DIRECTIVE_P (t) - && TREE_CODE (t) != OMP_RETURN - && TREE_CODE (t) != OMP_CONTINUE) + if (OMP_DIRECTIVE_P (t) && TREE_CODE (t) != OMP_RETURN_EXPR) { /* Do not remap variables inside OMP directives. Variables referenced in clauses and directive header belong to the @@ -4745,9 +4733,16 @@ find_outermost_region_in_block (struct function *src_cfun, int stmt_region; stmt_region = lookup_stmt_eh_region_fn (src_cfun, stmt); - if (stmt_region > 0 - && (region < 0 || eh_region_outer_p (src_cfun, stmt_region, region))) - region = stmt_region; + if (stmt_region > 0) + { + if (region < 0) + region = stmt_region; + else if (stmt_region != region) + { + region = eh_region_outermost (src_cfun, stmt_region, region); + gcc_assert (region != -1); + } + } } return region; |