changeset 5453:1ec29fc66504

8065618: C2 RA incorrectly removes kill projections Summary: Don't remove KILL projections if their "defining" nodes have SCMemProj projection (memory side effects). Reviewed-by: iveresov, roland
author kvn
date Tue, 02 Dec 2014 12:08:41 -0800
parents f49c3e79b676
children a7a359c825fa
files src/share/vm/opto/ifg.cpp
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/ifg.cpp	Mon Nov 24 16:33:20 2014 +0300
+++ b/src/share/vm/opto/ifg.cpp	Tue Dec 02 12:08:41 2014 -0800
@@ -571,6 +571,22 @@
           if( !n->is_Proj() ||
               // Could also be a flags-projection of a dead ADD or such.
               (n2lidx(def) && !liveout.member(n2lidx(def)) ) ) {
+            if (n->is_MachProj()) {
+              // Don't remove KILL projections if their "defining" nodes have
+              // memory effects (have SCMemProj projection node) -
+              // they are not dead even when their result is not used.
+              // For example, compareAndSwapL (and other CAS) and EncodeISOArray nodes.
+              // The method add_input_to_liveout() keeps such nodes alive (put them on liveout list)
+              // when it sees SCMemProj node in a block. Unfortunately SCMemProj node could be placed
+              // in block in such order that KILL MachProj nodes are processed first.
+              uint cnt = def->outcnt();
+              for (uint i = 0; i < cnt; i++) {
+                Node* proj = def->raw_out(i);
+                if (proj->Opcode() == Op_SCMemProj) {
+                  return false;
+                }
+              }
+            }
             b->_nodes.remove(j - 1);
             if( lrgs(r)._def == n ) lrgs(r)._def = 0;
             n->disconnect_inputs(NULL, C);