This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR debug/29232 [VTA] move assign rather than debug stmt in phiopt


On Sep  4, 2009, Richard Guenther <richard.guenther@gmail.com> wrote:

> On Thu, Sep 3, 2009 at 11:22 PM, Alexandre Oliva<aoliva@redhat.com> wrote:
>> 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.

> you added gsi_last_nondebug_bb, why not use that?

Err...  Is âOut of memoryâ an acceptable reason? :-)

Thanks, here's a revised patch with Jakub's fix and yours.  Is this one
ok?

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-04 15:22:01.000000000 -0300
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -g" } */
+extern int atoi (const char *);
+extern int sprintf (char *, const char *, ...);
+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-04 03:45:41.000000000 -0300
+++ gcc/tree-ssa-phiopt.c	2009-09-04 15:22:48.000000000 -0300
@@ -857,7 +857,7 @@ 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);
+      gsi_from = gsi_last_nondebug_bb (middle_bb);
       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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]