提交 8884e7cf 编写于 作者: K kvn

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
上级 c34a9c15
...@@ -1531,6 +1531,8 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { ...@@ -1531,6 +1531,8 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
return NULL; // No change return NULL; // No change
Node *top = phase->C->top(); 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 // The are 2 situations when only one valid phi's input is left
// (in addition to Region input). // (in addition to Region input).
...@@ -1550,6 +1552,12 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { ...@@ -1550,6 +1552,12 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
} }
} }
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); Node* uin = unique_input(phase);
if (uin == top) { // Simplest case: no alive inputs. if (uin == top) { // Simplest case: no alive inputs.
if (can_reshape) // IGVN transformation if (can_reshape) // IGVN transformation
...@@ -1684,8 +1692,7 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { ...@@ -1684,8 +1692,7 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
// Equivalent code is in MemNode::Ideal_common // Equivalent code is in MemNode::Ideal_common
Node *m = phase->transform(n); Node *m = phase->transform(n);
if (outcnt() == 0) { // Above transform() may kill us! if (outcnt() == 0) { // Above transform() may kill us!
progress = phase->C->top(); return top;
break;
} }
// If transformed to a MergeMem, get the desired slice // If transformed to a MergeMem, get the desired slice
// Otherwise the returned node represents memory for every slice // Otherwise the returned node represents memory for every slice
......
...@@ -240,13 +240,13 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { ...@@ -240,13 +240,13 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) {
// as a single huge transform. // as a single huge transform.
igvn->register_new_node_with_optimizer( region_c ); igvn->register_new_node_with_optimizer( region_c );
igvn->register_new_node_with_optimizer( region_x ); igvn->register_new_node_with_optimizer( region_x );
phi_x = phase->transform( phi_x );
// Prevent the untimely death of phi_x. Currently he has no uses. He is // Prevent the untimely death of phi_x. Currently he has no uses. He is
// about to get one. If this only use goes away, then phi_x will look dead. // about to get one. If this only use goes away, then phi_x will look dead.
// However, he will be picking up some more uses down below. // However, he will be picking up some more uses down below.
Node *hook = new (igvn->C, 4) Node(4); Node *hook = new (igvn->C, 4) Node(4);
hook->init_req(0, phi_x); hook->init_req(0, phi_x);
hook->init_req(1, phi_c); hook->init_req(1, phi_c);
phi_x = phase->transform( phi_x );
// Make the compare // Make the compare
Node *cmp_c = phase->makecon(t); Node *cmp_c = phase->makecon(t);
...@@ -322,6 +322,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { ...@@ -322,6 +322,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) {
phi_s = PhiNode::make_blank(region_s,phi); phi_s = PhiNode::make_blank(region_s,phi);
phi_s->init_req( 1, phi_c ); phi_s->init_req( 1, phi_c );
phi_s->init_req( 2, phi_x ); phi_s->init_req( 2, phi_x );
hook->add_req(phi_s);
phi_s = phase->transform(phi_s); phi_s = phase->transform(phi_s);
} }
proj_path_data = phi_s; proj_path_data = phi_s;
...@@ -333,6 +334,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { ...@@ -333,6 +334,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) {
phi_f = PhiNode::make_blank(region_f,phi); phi_f = PhiNode::make_blank(region_f,phi);
phi_f->init_req( 1, phi_c ); phi_f->init_req( 1, phi_c );
phi_f->init_req( 2, phi_x ); phi_f->init_req( 2, phi_x );
hook->add_req(phi_f);
phi_f = phase->transform(phi_f); phi_f = phase->transform(phi_f);
} }
proj_path_data = phi_f; proj_path_data = phi_f;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册