Skip to content

Commit 09dc585

Browse files
committed
re PR middle-end/58551 (ICE with abort in OpenMP SESE region inside of some loop)
PR middle-end/58551 * tree-cfg.c (move_sese_region_to_fn): Also move loops that are children of outermost saved_cfun's loop, and set it up to be moved to dest_cfun's outermost loop. Fix up num_nodes adjustments if loop != loop0 and SESE region contains bbs that belong to loop0. * c-c++-common/gomp/pr58551.c: New test. From-SVN: r202972
1 parent ec5a350 commit 09dc585

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

gcc/ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2013-09-27 Jakub Jelinek <[email protected]>
2+
3+
PR middle-end/58551
4+
* tree-cfg.c (move_sese_region_to_fn): Also move loops that
5+
are children of outermost saved_cfun's loop, and set it up to
6+
be moved to dest_cfun's outermost loop. Fix up num_nodes adjustments
7+
if loop != loop0 and SESE region contains bbs that belong to loop0.
8+
19
2013-09-27 Richard Sandiford <[email protected]>
210

311
* rtlanal.c (must_be_base_p, must_be_index_p): Delete.

gcc/testsuite/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2013-09-27 Jakub Jelinek <[email protected]>
2+
3+
PR middle-end/58551
4+
* c-c++-common/gomp/pr58551.c: New test.
5+
16
2013-09-27 Richard Biener <[email protected]>
27

38
PR tree-optimization/58459
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* PR middle-end/58551 */
2+
/* { dg-do compile } */
3+
/* { dg-options "-O0 -fopenmp" } */
4+
5+
void
6+
foo (int *a)
7+
{
8+
int i;
9+
for (i = 0; i < 8; i++)
10+
#pragma omp task
11+
if (a[i])
12+
__builtin_abort ();
13+
}
14+
15+
void bar (int, int);
16+
17+
void
18+
baz (int *a)
19+
{
20+
int i;
21+
for (i = 0; i < 8; i++)
22+
#pragma omp task
23+
if (a[i])
24+
{
25+
int j, k;
26+
for (j = 0; j < 10; j++)
27+
for (k = 0; k < 8; k++)
28+
bar (j, k);
29+
for (k = 0; k < 12; k++)
30+
bar (-1, k);
31+
__builtin_abort ();
32+
}
33+
}

gcc/tree-cfg.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6662,12 +6662,13 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
66626662
struct function *saved_cfun = cfun;
66636663
int *entry_flag, *exit_flag;
66646664
unsigned *entry_prob, *exit_prob;
6665-
unsigned i, num_entry_edges, num_exit_edges;
6665+
unsigned i, num_entry_edges, num_exit_edges, num_nodes;
66666666
edge e;
66676667
edge_iterator ei;
66686668
htab_t new_label_map;
66696669
struct pointer_map_t *vars_map, *eh_map;
66706670
struct loop *loop = entry_bb->loop_father;
6671+
struct loop *loop0 = get_loop (saved_cfun, 0);
66716672
struct move_stmt_d d;
66726673

66736674
/* If ENTRY does not strictly dominate EXIT, this cannot be an SESE
@@ -6760,16 +6761,29 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
67606761
set_loops_for_fn (dest_cfun, loops);
67616762

67626763
/* Move the outlined loop tree part. */
6764+
num_nodes = bbs.length ();
67636765
FOR_EACH_VEC_ELT (bbs, i, bb)
67646766
{
6765-
if (bb->loop_father->header == bb
6766-
&& loop_outer (bb->loop_father) == loop)
6767+
if (bb->loop_father->header == bb)
67676768
{
67686769
struct loop *this_loop = bb->loop_father;
6769-
flow_loop_tree_node_remove (bb->loop_father);
6770-
flow_loop_tree_node_add (get_loop (dest_cfun, 0), this_loop);
6771-
fixup_loop_arrays_after_move (saved_cfun, cfun, this_loop);
6770+
struct loop *outer = loop_outer (this_loop);
6771+
if (outer == loop
6772+
/* If the SESE region contains some bbs ending with
6773+
a noreturn call, those are considered to belong
6774+
to the outermost loop in saved_cfun, rather than
6775+
the entry_bb's loop_father. */
6776+
|| outer == loop0)
6777+
{
6778+
if (outer != loop)
6779+
num_nodes -= this_loop->num_nodes;
6780+
flow_loop_tree_node_remove (bb->loop_father);
6781+
flow_loop_tree_node_add (get_loop (dest_cfun, 0), this_loop);
6782+
fixup_loop_arrays_after_move (saved_cfun, cfun, this_loop);
6783+
}
67726784
}
6785+
else if (bb->loop_father == loop0 && loop0 != loop)
6786+
num_nodes--;
67736787

67746788
/* Remove loop exits from the outlined region. */
67756789
if (loops_for_fn (saved_cfun)->exits)
@@ -6789,6 +6803,7 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
67896803

67906804
/* Setup a mapping to be used by move_block_to_fn. */
67916805
loop->aux = current_loops->tree_root;
6806+
loop0->aux = current_loops->tree_root;
67926807

67936808
pop_cfun ();
67946809

@@ -6817,11 +6832,13 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
68176832
}
68186833

68196834
loop->aux = NULL;
6835+
loop0->aux = NULL;
68206836
/* Loop sizes are no longer correct, fix them up. */
6821-
loop->num_nodes -= bbs.length ();
6837+
loop->num_nodes -= num_nodes;
68226838
for (struct loop *outer = loop_outer (loop);
68236839
outer; outer = loop_outer (outer))
6824-
outer->num_nodes -= bbs.length ();
6840+
outer->num_nodes -= num_nodes;
6841+
loop0->num_nodes -= bbs.length () - num_nodes;
68256842

68266843
if (saved_cfun->has_simduid_loops || saved_cfun->has_force_vect_loops)
68276844
{

0 commit comments

Comments
 (0)