This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR debug/29232 [VTA] move assign rather than debug stmt in phiopt
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 03 Sep 2009 18:22:19 -0300
- Subject: PR debug/29232 [VTA] move assign rather than debug stmt in phiopt
tree-ssa-phiopt.c's minmax replacement will sometimes attempt to move
the only non-debug stmt in a block to another block. The assumption
that the assignment to be moved is the last in the block is correct only
if there aren't any debug stmts after it. In the presented testcase,
there is, and so we ended up moving the debug stmt rather than the
assignment. Then, when the block with the assignment was removed,
verify_ssa noticed something was broken.
The obvious fix is to skip debug stmts at the end of the block before
moving the assignment. Unless someone objects, I'll check this in as
obvious once my testing is completed.
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41232
* tree-ssa-phiopt.c (minmax_replacement): Skip debug stmts
in the middle block.
for gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41232
* gcc.dg/pr41232.c: New.
Index: gcc/testsuite/gcc.dg/pr41232.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.dg/pr41232.c 2009-09-03 17:51:15.000000000 -0300
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -g" } */
+void malloc_init() {
+ char *cptr;
+ char buf[1];
+ int tmbd = atoi(cptr);
+ if (tmbd > 0)
+ tmbd = (tmbd <= 124) ? tmbd : 124;
+ else
+ tmbd = 0;
+ sprintf(buf, "%d\n", tmbd);
+}
Index: gcc/tree-ssa-phiopt.c
===================================================================
--- gcc/tree-ssa-phiopt.c.orig 2009-09-03 18:01:44.000000000 -0300
+++ gcc/tree-ssa-phiopt.c 2009-09-03 18:10:35.000000000 -0300
@@ -858,6 +858,8 @@ minmax_replacement (basic_block cond_bb,
/* Move the statement from the middle block. */
gsi = gsi_last_bb (cond_bb);
gsi_from = gsi_last_bb (middle_bb);
+ if (is_gimple_debug (gsi_stmt (gsi_from)))
+ gsi_prev_nondebug (&gsi_from);
gsi_move_before (&gsi_from, &gsi);
}
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist Red Hat Brazil Compiler Engineer