From: Jakub Jelinek Date: Fri, 31 May 2019 07:53:48 +0000 (+0200) Subject: re PR tree-optimization/90671 (ICE on valid code at -Os and above with -g enabled... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6992d6fbf2ffdb4a5c78604fbf33ae95956fffdd;p=gcc.git re PR tree-optimization/90671 (ICE on valid code at -Os and above with -g enabled in gsi_split_seq_after, at gimple-iterator.c:345) PR tree-optimization/90671 * tree-ssa-threadupdate.c (ssa_create_duplicates): If template_block used to be empty on the first call, don't use gsi_split_seq_after and gsi_insert_seq_after, but remember whole seq with bb_seq and set it with set_bb_seq. * gcc.dg/torture/pr90671.c: New test. From-SVN: r271802 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e3792c6ee85..5283feda9d5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-05-31 Jakub Jelinek + + PR tree-optimization/90671 + * tree-ssa-threadupdate.c (ssa_create_duplicates): If + template_block used to be empty on the first call, don't use + gsi_split_seq_after and gsi_insert_seq_after, but remember whole + seq with bb_seq and set it with set_bb_seq. + 2019-05-31 Iain Sandoe * config/i386/darwin.h (ASM_OUTPUT_MAX_SKIP_ALIGN): New. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 341dc4c4ecc..c081448df40 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-05-31 Jakub Jelinek + + PR tree-optimization/90671 + * gcc.dg/torture/pr90671.c: New test. + 2019-05-31 Iain Sandoe * g++.dg/cpp0x/pr84497.C: Require alias support. diff --git a/gcc/testsuite/gcc.dg/torture/pr90671.c b/gcc/testsuite/gcc.dg/torture/pr90671.c new file mode 100644 index 00000000000..5a99b9d9a84 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr90671.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/90671 */ +/* { dg-do compile } */ +/* { dg-additional-options "-w -g" } */ + +int a; + +int +main () +{ + int b, c; + for (c = 0; c < 2; c++) + while (a) + if (b) + break; + return 0; +} diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index d6315431774..a56ccfbaa8c 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -1142,12 +1142,25 @@ ssa_create_duplicates (struct redirection_data **slot, gimple_seq seq = NULL; if (gsi_stmt (local_info->template_last_to_copy) != gsi_stmt (gsi_last_bb (local_info->template_block))) - seq = gsi_split_seq_after (local_info->template_last_to_copy); + { + if (gsi_end_p (local_info->template_last_to_copy)) + { + seq = bb_seq (local_info->template_block); + set_bb_seq (local_info->template_block, NULL); + } + else + seq = gsi_split_seq_after (local_info->template_last_to_copy); + } create_block_for_threading (local_info->template_block, rd, 0, &local_info->duplicate_blocks); if (seq) - gsi_insert_seq_after (&local_info->template_last_to_copy, - seq, GSI_SAME_STMT); + { + if (gsi_end_p (local_info->template_last_to_copy)) + set_bb_seq (local_info->template_block, seq); + else + gsi_insert_seq_after (&local_info->template_last_to_copy, + seq, GSI_SAME_STMT); + } /* Go ahead and wire up outgoing edges and update PHIs for the duplicate block. */