[patch] for PR 28121

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Wed Jun 21 23:34:00 GMT 2006


Hello,

this PR is caused by an edge with EDGE_EXECUTABLE flag set during rtl
optimizations (cfg verification ices for it, although with a bit
missleading error message).  We clean up EDGE_EXECUTABLE flag during
tree to rtl expansion, but we forget to clean it on the entry edge.
During the optimizations, entry edge gets split and the flag gets inside
CFG.  This patch makes us clean the flag from the entry edge as well.

Bootstrapped & regtested on i686.

Zdenek

	PR rtl-optimization/28121
	* cfgexpand.c (tree_expand_cfg): Clean EDGE_EXECUTABLE flag from
	the entry edge.

	* gcc.dg/pr28121.c: New test.

Index: testsuite/gcc.dg/pr28121.c
===================================================================
*** testsuite/gcc.dg/pr28121.c	(revision 0)
--- testsuite/gcc.dg/pr28121.c	(revision 0)
***************
*** 0 ****
--- 1,27 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2" } */
+ 
+ short
+ GetCmd ()
+ {
+   int c, c1;
+   for (c = 255; c == 255;)
+     {
+       c = GetMouseButton ();
+       if (c >= 0)
+ 	{
+ 	  c = ParsePos (c, -1, 0);
+ 	  c1 = ParsePos (c1, c, 1);
+ 	  if (c == c1 && (c >= 0 || c == -10))
+ 	    {
+ 	      return c;
+ 	    }
+ 	  if (c >= 0 && c1 == -12)
+ 	    {
+ 	      return ((((((10) + 1) + 1)) + 1) << 7) | c;
+ 	    }
+ 	  c = 255;
+ 	}
+     }
+ }
+ 
Index: cfgexpand.c
===================================================================
*** cfgexpand.c	(revision 114850)
--- cfgexpand.c	(working copy)
*************** tree_expand_cfg (void)
*** 1580,1585 ****
--- 1580,1587 ----
  {
    basic_block bb, init_block;
    sbitmap blocks;
+   edge_iterator ei;
+   edge e;
  
    /* Some backends want to know that we are expanding to RTL.  */
    currently_expanding_to_rtl = 1;
*************** tree_expand_cfg (void)
*** 1623,1628 ****
--- 1625,1635 ----
  
    init_block = construct_init_block ();
  
+   /* Clear EDGE_EXECUTABLE on the entry edge(s).  It is cleaned from the
+      remainining edges in expand_gimple_basic_block.  */
+   FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
+     e->flags &= ~EDGE_EXECUTABLE;
+ 
    FOR_BB_BETWEEN (bb, init_block->next_bb, EXIT_BLOCK_PTR, next_bb)
      bb = expand_gimple_basic_block (bb);
  



More information about the Gcc-patches mailing list