[tree-ssa] Bug in jump threading

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Thu Feb 5 10:00:00 GMT 2004


Hello,

the jump threading works incorrectly in this situation:

x_1 = pointer;
t_1 = x_1->field;

if (t_1)
  goto L1;

  ...


L1:
  x1_1 = pointer;
  if (!x1_1)
    goto L2;

...

L2:
  x1_2 = phi (..., x1_1 (from L1 block));
  ...

before the goto L1 is threaded to L2, variables are rewritten out of
ssa:

x = pointer;
t_1 = x->field;

if (t_1)
  goto L1;

  ...


L1:
  x1 = pointer;
  if (!x1)
    goto L2;

  ...

L2:
  ...

Now when you thread the jump, you lose the assignment to x1.

Can be reproduced using attached testcase -- ./cc1 -O1 -Wuninitialized tc1.i

It prevents my loop header copying patch from bootstrapping, so it would
be nice if you could do something with it.

Zdenek
-------------- next part --------------
typedef union tree_node *tree;

struct tree_common
{
  tree chain;
};

struct tree_decl
{
  struct tree_common common;
  tree name;
};


union tree_node
{
  struct tree_common common;
  struct tree_decl decl;
};

int pedantic;

void
finish_struct (tree t, tree fieldlist, tree attributes)
{
  union tree_node * x;

  if (pedantic)
    {
      x = fieldlist;
      if (x->decl.name == 0)
	{
	  while (x)
	    x = x->common.chain;
	  foo (fieldlist);
	}
    }

  x = fieldlist;
  if (x)
    {
      do
	{
	  x = x->common.chain;
	} while (x != 0);
    }
  
  bar1 (&fieldlist);
}


More information about the Gcc mailing list