This is the mail archive of the 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]

[patch] PR19217 - disable ADDR_EXPR checks in verify_stmts


PR tree-optimization/19217 ( is about an
overzealous tree check for addressable variables.  The bug is only
triggered in compilers compiled with checking enabled.

The problem is that verify_stmts is verifying the TREE_ADDRESSABLE
bits for each ADDR_EXPR it sees.  But an ADDR_EXPR is not a statement
and being addressable is a symbol property, not a statement property.
So as we walk all statements, including dead statements, we perform
checks on statements that are ignored by passes that walk SSA use-def
chains, skipping dead code.  For this bug that pass is the alias pass.

The alias pass clears the TREE_ADDRESSABLE bit on non-addressable
symbols.  It determines that a symbol is not addressable if it is not
seen in an ADDR_EXPR in a walk of the use-def chains that the symbol
appears in (and satisfies a few other conditions that do not matter
for this bug).  Consider the following test case, with a tree dump
after CCP (the .alias4 dump, just before we ICE):

flexto(int *current,int instance_count)
  int *end, temp, j;
  if (0<instance_count)
    end = &temp;
  *current = *end;

--> .alias4 tree dump:

flexto (currentD.1447, instance_countD.1448)
  intD.0 jD.1453;
  intD.0 tempD.1452;
  intD.0 * endD.1451;
  intD.0 D.1454;

  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  if (instance_countD.1448_2 > 0) goto <L0>; else goto <L1>;
  # SUCC: 1 [88.4%]  (true,exec) 2 [11.6%]  (false,exec)

  # BLOCK 1
  # PRED: 0 [88.4%]  (true,exec)
  # SUCC: 2 [100.0%]  (fallthru,exec)

  # BLOCK 2
  # PRED: 0 [11.6%]  (false,exec) 1 [100.0%]  (fallthru,exec)
  # endD.1451_1 = PHI <endD.1451_3(0), &tempD.1452(1)>;
  D.1454_4 = tempD.1452_7;
  #   TMT.0D.1463_9 = V_MAY_DEF <TMT.0D.1463_6>;
  *currentD.1447_5 = D.1454_4;
  # SUCC: EXIT [100.0%]


Note the dead PHI node with PHI result endD.1451_1.  DCE would have
cleaned it up but it is not run between ccp and alias4 (with checking
disabled, the PHI is removed in the final DCE pass).  Now, alias walks
the use-def chains.  The following comment (tree-ssa-alias.c):

    /* Mark all the variables whose address are taken by the
       statement.  Note that this will miss all the addresses taken
       in PHI nodes (those are discovered while following the use-def
       chains).  */

means that we will not visit the dead PHI, and so TREE_ADDRESSABLE for 
tempD.1452 is cleared.  This leads to the ICE in verify_stmts:

t.c: In function 'flexto':
t.c:3: error: address taken, but ADDRESSABLE bit not set

t.c:3: internal compiler error: verify_stmts failed.

There is really not much we can or would want to do about this in
tree-ssa-alias.c.  The results are valid if you do not take dead code
into account.  I think you don't *want* to take dead code into account
because it means you either have to purge all dead code before each
may-alias pass, or you pessimize your analysis.

And, as I said above, IMHO verify_stmts should not be performing this
check to begin with.  Perhaps there should be a verify_alias pass, or
maybe it should go into verify_ssa - but at least not in verify_stmts.

So the patch below just kicks out the check.  I have only commented it
out because maybe someone wants to resurrect it elsewhere if this patch
is OKed.

Bootstrapped on x86_65-unknown-linux-gnu.
OK for mainline?


	PR tree-optimization/19217
	* tree-cfg.c (verify_expr): Comment out the ADDR_EXPR check.

Index: tree-cfg.c
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.147
diff -u -3 -p -r2.147 tree-cfg.c
--- tree-cfg.c	22 Jan 2005 17:52:36 -0000	2.147
+++ tree-cfg.c	1 Feb 2005 11:07:24 -0000
@@ -3269,6 +3269,7 @@ verify_expr (tree *tp, int *walk_subtree
+#if 0
     case ADDR_EXPR:
       /* Skip any references (they will be checked when we recurse down the
 	 tree) and ensure that any variable used as a prefix is marked
@@ -3286,6 +3287,7 @@ verify_expr (tree *tp, int *walk_subtree
 	  return x;
     case COND_EXPR:
       x = COND_EXPR_COND (t);

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