From 650a8fcf8cabb103e1e1cbd40711f1decbb09d5e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 6 Dec 2017 09:16:44 +0100 Subject: re PR tree-optimization/81945 (ICE in operator[], at vec.h:749) PR tree-optimization/81945 * cfgloop.h (FOR_EACH_LOOP_FN): Use FN instead of hardcoding fn. * tree-cfg.c (move_sese_region_to_fn): If any of the loops moved to dest_cfun has orig_loop_num set, either remap it to the new loop number if the loop got moved too, or clear it. * gcc.dg/graphite/pr81945.c: New test. From-SVN: r255438 --- gcc/tree-cfg.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/tree-cfg.c') diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 2501a9c..e313df9 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -7468,6 +7468,8 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES; set_loops_for_fn (dest_cfun, loops); + vec *larray = get_loops (saved_cfun)->copy (); + /* Move the outlined loop tree part. */ num_nodes = bbs.length (); FOR_EACH_VEC_ELT (bbs, i, bb) @@ -7514,6 +7516,20 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, loop->aux = current_loops->tree_root; loop0->aux = current_loops->tree_root; + /* Fix up orig_loop_num. If the block referenced in it has been moved + to dest_cfun, update orig_loop_num field, otherwise clear it. */ + struct loop *dloop; + FOR_EACH_LOOP_FN (dest_cfun, dloop, 0) + if (dloop->orig_loop_num) + { + if ((*larray)[dloop->orig_loop_num] != NULL + && get_loop (saved_cfun, dloop->orig_loop_num) == NULL) + dloop->orig_loop_num = (*larray)[dloop->orig_loop_num]->num; + else + dloop->orig_loop_num = 0; + } + ggc_free (larray); + pop_cfun (); /* Move blocks from BBS into DEST_CFUN. */ -- cgit v1.1