On 4/10/07, Andrew Pinski <[EMAIL PROTECTED]> wrote:
On 4/10/07, Andrew Pinski <[EMAIL PROTECTED]> wrote:
> Here is the quick patch (thanks to the work done for gimple tuple)
> which does this, removes the unneeded type from phi nodes.  I have not
> tested it except for a quick test on some small testcases so there
> might be more places which use TREE_CHAIN instead of PHI_CHAIN.

This patch has one problem, the GC issue with chain_next and
lang_tree_node, this problem is not hard to fix.

And here is that patch still not fully test except this time compiling
some simple C++ code and without ICEing in the gc collect :).

Thanks,
Andrew Pinski
Index: tree.h
===================================================================
--- tree.h      (revision 123697)
+++ tree.h      (working copy)
@@ -951,7 +951,7 @@
   (TREE_CODE_CLASS (TREE_CODE ((NODE))) == tcc_gimple_stmt)
 
 /* Nonzero if NODE is a GIMPLE tuple.  */
-#define GIMPLE_TUPLE_P(NODE) (GIMPLE_STMT_P (NODE))
+#define GIMPLE_TUPLE_P(NODE) (GIMPLE_STMT_P (NODE) || TREE_CODE (NODE) == 
PHI_NODE)
 
 /* A GIMPLE tuple that has a ``locus'' field.  */
 #define GIMPLE_TUPLE_HAS_LOCUS_P(NODE) GIMPLE_STMT_P ((NODE))
@@ -975,6 +975,11 @@
    used in hash tables which are saved to a PCH.  */
 #define TREE_HASH(NODE) ((size_t) (NODE) & 0777777)
 
+/* The TREE_CHAIN but it is able to handle tuples.  */
+#define GENERIC_NEXT(NODE)                                     \
+  (TREE_CODE (NODE) == PHI_NODE ? PHI_CHAIN (NODE) :           \
+     GIMPLE_STMT_P (NODE) ? NULL_TREE : TREE_CHAIN (NODE))
+
 /* Given an expression as a tree, strip any NON_LVALUE_EXPRs and NOP_EXPRs
    that don't change the machine mode.  */
 
@@ -1866,7 +1871,7 @@
 /* PHI_NODEs for each basic block are chained together in a single linked
    list.  The head of the list is linked from the block annotation, and
    the link to the next PHI is in PHI_CHAIN.  */
-#define PHI_CHAIN(NODE)                TREE_CHAIN (PHI_NODE_CHECK (NODE))
+#define PHI_CHAIN(NODE)                        PHI_NODE_CHECK (NODE)->phi.chain
 
 #define PHI_NUM_ARGS(NODE)             PHI_NODE_CHECK (NODE)->phi.num_args
 #define PHI_ARG_CAPACITY(NODE)         PHI_NODE_CHECK (NODE)->phi.capacity
@@ -1885,7 +1890,8 @@
 
 struct tree_phi_node GTY(())
 {
-  struct tree_common common;
+  struct tree_base common;
+  tree chain;
   tree result;
   int num_args;
   int capacity;
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c      (revision 123697)
+++ tree-ssa-structalias.c      (working copy)
@@ -4730,7 +4730,7 @@
       block_stmt_iterator bsi;
       tree phi;
 
-      for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
+      for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
        {
          if (is_gimple_reg (PHI_RESULT (phi)))
            {
@@ -4882,7 +4882,7 @@
              block_stmt_iterator bsi;
              tree phi;
 
-             for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
+             for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
                {
                  if (is_gimple_reg (PHI_RESULT (phi)))
                    {
Index: tree-phinodes.c
===================================================================
--- tree-phinodes.c     (revision 123697)
+++ tree-phinodes.c     (working copy)
@@ -218,7 +218,6 @@
   TREE_SET_CODE (phi, PHI_NODE);
   PHI_NUM_ARGS (phi) = len;
   PHI_ARG_CAPACITY (phi) = capacity;
-  TREE_TYPE (phi) = TREE_TYPE (var);
   if (TREE_CODE (var) == SSA_NAME)
     SET_PHI_RESULT (phi, var);
   else
Index: ada/ada-tree.h
===================================================================
--- ada/ada-tree.h      (revision 123697)
+++ ada/ada-tree.h      (working copy)
@@ -36,7 +36,7 @@
 /* Ada uses the lang_decl and lang_type fields to hold a tree.  */
 union lang_tree_node
   GTY((desc ("0"),
-       chain_next ("(GIMPLE_STMT_P (&%h.t) ? (union lang_tree_node *) 0 : 
(union lang_tree_node *)TREE_CHAIN (&%h.t))")))
+       chain_next ("GENERIC_NEXT (&%h.generic)")))
 
 {
   union tree_node GTY((tag ("0"))) t;
Index: java/java-tree.h
===================================================================
--- java/java-tree.h    (revision 123697)
+++ java/java-tree.h    (working copy)
@@ -667,7 +667,7 @@
 /* The resulting tree type.  */
 union lang_tree_node 
   GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
-       chain_next ("(GIMPLE_STMT_P (&%h.generic) ? (union lang_tree_node *) 0 
: (union lang_tree_node *)TREE_CHAIN (&%h.generic))")))
+       chain_next ("GENERIC_NEXT (&%h.generic)")))
 
 {
   union tree_node GTY ((tag ("0"), 
Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h        (revision 123697)
+++ cp/cp-tree.h        (working copy)
@@ -539,7 +539,7 @@
 
 /* The resulting tree type.  */
 union lang_tree_node GTY((desc ("cp_tree_node_structure (&%h)"),
-       chain_next ("(GIMPLE_STMT_P (&%h.generic) ? (union lang_tree_node *) 0 
: (union lang_tree_node *)TREE_CHAIN (&%h.generic))")))
+       chain_next ("GENERIC_NEXT (&%h.generic)")))
 {
   union tree_node GTY ((tag ("TS_CP_GENERIC"),
                        desc ("tree_node_structure (&%h)"))) generic;

Reply via email to