diff src/share/vm/opto/cfgnode.cpp @ 1013:ce590301ae2a

6889300: assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes") Summary: PhiNode::Ideal() should return TOP for Phi node with no users. Reviewed-by: never, jrose
author kvn
date Tue, 13 Oct 2009 22:32:31 -0700
parents 15bbd3f505c0
children ae4032fb0a5b eb79484f795f
line wrap: on
line diff
--- a/src/share/vm/opto/cfgnode.cpp	Tue Oct 13 20:54:13 2009 -0700
+++ b/src/share/vm/opto/cfgnode.cpp	Tue Oct 13 22:32:31 2009 -0700
@@ -1531,6 +1531,8 @@
     return NULL;                // No change
 
   Node *top = phase->C->top();
+  bool new_phi = (outcnt() == 0); // transforming new Phi
+  assert(!can_reshape || !new_phi, "for igvn new phi should be hooked");
 
   // The are 2 situations when only one valid phi's input is left
   // (in addition to Region input).
@@ -1550,6 +1552,12 @@
     }
   }
 
+  if (can_reshape && outcnt() == 0) {
+    // set_req() above may kill outputs if Phi is referenced
+    // only by itself on the dead (top) control path.
+    return top;
+  }
+
   Node* uin = unique_input(phase);
   if (uin == top) {             // Simplest case: no alive inputs.
     if (can_reshape)            // IGVN transformation
@@ -1684,8 +1692,7 @@
             // Equivalent code is in MemNode::Ideal_common
             Node *m  = phase->transform(n);
             if (outcnt() == 0) {  // Above transform() may kill us!
-              progress = phase->C->top();
-              break;
+              return top;
             }
             // If transformed to a MergeMem, get the desired slice
             // Otherwise the returned node represents memory for every slice