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]

fix tree-opt/10528


This *may* fix up many of the things that Andrew Pinski has
been noticing with failed propagation.  I couldn't find his
examples for which he was suggesting the introduction of a
new propataion pass.

The test case I actually worked from was

	struct A
	{
	  virtual void a();
	  int x;
	};
	struct C : public A
	{
	  virtual void a();
	};
	C obj;

In which, at the end of tree optimization we should *not* see,
in the code for the global constructor,

  this = &obj.D.1575;
  this->_vptr.A = &_ZTV1A[2];

The problem, as expected, was an ADDR_EXPR without the proper
TREE_INVARIANT bit set.  What was surprising is that how early
we get things wrong -- the substitution happens during inlining.

There may be other PRs that this fixes, but this one was already
assigned to me.

Bootstrapped and tested on i686-linux.


r~



        PR tree-opt/10528
        * tree-inline.c (copy_body_r): Recompute bits for ADDR_EXPR,
        after copying its argument.

Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.139
diff -u -p -r1.139 tree-inline.c
--- tree-inline.c	9 Sep 2004 13:38:53 -0000	1.139
+++ tree-inline.c	13 Sep 2004 02:14:57 -0000
@@ -619,6 +619,16 @@ copy_body_r (tree *tp, int *walk_subtree
 	  TREE_OPERAND (*tp, 1) = TREE_OPERAND (*tp, 3);
 	  TREE_OPERAND (*tp, 3) = NULL_TREE;
 	}
+
+      /* Variable substitution need not be simple.  In particular, the
+	 INDIRECT_REF substitution above.  Make sure that TREE_CONSTANT
+	 and friends are up-to-date.  */
+      else if (TREE_CODE (*tp) == ADDR_EXPR)
+	{
+	  walk_tree (&TREE_OPERAND (*tp, 0), copy_body_r, id, NULL);
+	  recompute_tree_invarant_for_addr_expr (*tp);
+	  *walk_subtrees = 0;
+	}
     }
 
   /* Keep iterating.  */


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