public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR54327
@ 2012-08-20 10:24 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2012-08-20 10:24 UTC (permalink / raw)
  To: gcc-patches


This is an issue of folding looking at SSA def stmts when SSA form
is not up-to-date.  That's not safe unless the SSA name we are
looking at is not marked for update (see GIMPLE_COND folding in
cfgcleaup for another example).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2012-08-20  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/54327
	* gimple-fold.c (get_maxval_strlen): Do not walk use-def chains
	if the use is registered for SSA update.

	* gcc.dg/torture/pr54327.c: New testcase.

Index: gcc/gimple-fold.c
===================================================================
*** gcc/gimple-fold.c	(revision 190523)
--- gcc/gimple-fold.c	(working copy)
*************** get_maxval_strlen (tree arg, tree *lengt
*** 736,741 ****
--- 736,746 ----
        return true;
      }
  
+   /* If ARG is registered for SSA update we cannot look at its defining
+      statement.  */
+   if (name_registered_for_update_p (arg))
+     return false;
+ 
    /* If we were already here, break the infinite cycle.  */
    if (!bitmap_set_bit (visited, SSA_NAME_VERSION (arg)))
      return true;
Index: gcc/testsuite/gcc.dg/torture/pr54327.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr54327.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr54327.c	(working copy)
***************
*** 0 ****
--- 1,15 ----
+ /* { dg-do compile } */
+ 
+ #include <string.h>
+ #include <stdlib.h>
+ void treathead ()
+ {
+   char *a = ';' == '\0' ? : 0;
+   if (*a == '=')
+     {
+       while (*a == (*a == 0) || *a == '\'')
+ 	a++;
+       if (strlen (a) < 2)
+ 	abort ();
+     }
+ }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-08-20 10:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-20 10:24 [PATCH] Fix PR54327 Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).