From: Jakub Jelinek Date: Wed, 25 Mar 2020 07:08:04 +0000 (+0100) Subject: if-conv: Delete dead stmts backwards in ifcvt_local_dce [PR94283] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c2133167ad58d15c2c2df0cb4fa3a3757603144e;p=gcc.git if-conv: Delete dead stmts backwards in ifcvt_local_dce [PR94283] > > This patch caused: > > > > gcc /home/marxin/Programming/gcc/gcc/testsuite/gcc.c-torture/compile/990625-2.c -O3 -g -fno-tree-dce -c > > during GIMPLE pass: ifcvt > > /home/marxin/Programming/gcc/gcc/testsuite/gcc.c-torture/compile/990625-2.c: In function ‘broken030599’: > > /home/marxin/Programming/gcc/gcc/testsuite/gcc.c-torture/compile/990625-2.c:2:1: internal compiler error: Segmentation fault > > Likely > > /* Delete dead statements. */ > gsi = gsi_start_bb (bb); > while (!gsi_end_p (gsi)) > { > > needs to instead work back-to-front for debug stmt adjustment to work Indeed, that seems to work. 2020-03-25 Richard Biener Jakub Jelinek PR debug/94283 * tree-if-conv.c (ifcvt_local_dce): Delete dead statements backwards. * gcc.dg/pr94283.c: New test. Co-authored-by: Richard Biener --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4edf2128efb..485fc09464a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-03-25 Richard Biener + Jakub Jelinek + + PR debug/94283 + * tree-if-conv.c (ifcvt_local_dce): Delete dead statements backwards. + 2020-03-24 Christophe Lyon * doc/sourcebuild.texi (ARM-specific attributes): Add diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 56a630412ab..5a428085aab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-03-25 Jakub Jelinek + + PR debug/94283 + * gcc.dg/pr94283.c: New test. + 2020-03-24 Sandra Loosemore * gcc.dg/analyzer/sigsetjmp-5.c: Require sigsetjmp support. diff --git a/gcc/testsuite/gcc.dg/pr94283.c b/gcc/testsuite/gcc.dg/pr94283.c new file mode 100644 index 00000000000..ac162d6ac7b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr94283.c @@ -0,0 +1,16 @@ +/* PR debug/94283 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-dce -fcompare-debug" } */ + +void +foo (int *n) +{ + for (int i = 0; i < 32; i++) + { + int x = 0; + x++; + if (i & 4) + x++; + x++; + } +} diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index dd11d805c77..fc894eb94da 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -2973,9 +2973,11 @@ ifcvt_local_dce (class loop *loop) } } /* Delete dead statements. */ - gsi = gsi_start_bb (bb); + gsi = gsi_last_bb (bb); while (!gsi_end_p (gsi)) { + gimple_stmt_iterator gsiprev = gsi; + gsi_prev (&gsiprev); stmt = gsi_stmt (gsi); if (gimple_store_p (stmt)) { @@ -2986,14 +2988,13 @@ ifcvt_local_dce (class loop *loop) if (dse_classify_store (&write, stmt, false, NULL, NULL, latch_vdef) == DSE_STORE_DEAD) delete_dead_or_redundant_assignment (&gsi, "dead"); - else - gsi_next (&gsi); + gsi = gsiprev; continue; } if (gimple_plf (stmt, GF_PLF_2)) { - gsi_next (&gsi); + gsi = gsiprev; continue; } if (dump_file && (dump_flags & TDF_DETAILS)) @@ -3003,6 +3004,7 @@ ifcvt_local_dce (class loop *loop) } gsi_remove (&gsi, true); release_defs (stmt); + gsi = gsiprev; } }