aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gfortran.dg/pr94285.f905
-rw-r--r--gcc/tree-ssa-loop-manip.c12
4 files changed, 23 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 51cb52d..976f87c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2020-03-24 Jakub Jelinek <jakub@redhat.com>
+ PR debug/94285
+ * tree-ssa-loop-manip.c (create_iv): If after, set stmt location to
+ e->goto_locus even if gsi_bb (*incr_pos) contains only debug stmts.
+ If not after and at *incr_pos is a debug stmt, set stmt location to
+ location of next non-debug stmt after it if any.
+
PR debug/94283
* tree-if-conv.c (ifcvt_local_dce): For gimple debug stmts, just set
GF_PLF_2, but don't add them to worklist. Don't add an assigment to
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e050d15..de25dfb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2020-03-24 Jakub Jelinek <jakub@redhat.com>
+ PR debug/94285
+ * gfortran.dg/pr94285.f90: New test.
+
PR debug/94283
* gcc.target/i386/pr94283.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr94285.f90 b/gcc/testsuite/gfortran.dg/pr94285.f90
new file mode 100644
index 0000000..8ee7f7f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr94285.f90
@@ -0,0 +1,5 @@
+! PR debug/94285
+! { dg-do compile }
+! { dg-options "-Os -fno-tree-dominator-opts -fno-tree-vrp -fcompare-debug" }
+
+include 'array_constructor_40.f90'
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 120b35b..a2717a4 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -129,7 +129,10 @@ create_iv (tree base, tree step, tree var, class loop *loop,
immediately after a statement whose location is known. */
if (after)
{
- if (gsi_end_p (*incr_pos))
+ if (gsi_end_p (*incr_pos)
+ || (is_gimple_debug (gsi_stmt (*incr_pos))
+ && gsi_bb (*incr_pos)
+ && gsi_end_p (gsi_last_nondebug_bb (gsi_bb (*incr_pos)))))
{
edge e = single_succ_edge (gsi_bb (*incr_pos));
gimple_set_location (stmt, e->goto_locus);
@@ -138,8 +141,11 @@ create_iv (tree base, tree step, tree var, class loop *loop,
}
else
{
- if (!gsi_end_p (*incr_pos))
- gimple_set_location (stmt, gimple_location (gsi_stmt (*incr_pos)));
+ gimple_stmt_iterator gsi = *incr_pos;
+ if (!gsi_end_p (gsi) && is_gimple_debug (gsi_stmt (gsi)))
+ gsi_next_nondebug (&gsi);
+ if (!gsi_end_p (gsi))
+ gimple_set_location (stmt, gimple_location (gsi_stmt (gsi)));
gsi_insert_before (incr_pos, stmt, GSI_NEW_STMT);
}