diff src/share/vm/opto/ifg.cpp @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 52b4284cb496 3f4a5fdca318
children
line wrap: on
line diff
--- a/src/share/vm/opto/ifg.cpp	Tue Apr 07 11:20:51 2015 +0200
+++ b/src/share/vm/opto/ifg.cpp	Tue Apr 07 14:58:49 2015 +0200
@@ -541,17 +541,37 @@
           if( !n->is_Proj() ||
               // Could also be a flags-projection of a dead ADD or such.
               (_lrg_map.live_range_id(def) && !liveout.member(_lrg_map.live_range_id(def)))) {
-            block->remove_node(j - 1);
-            if (lrgs(r)._def == n) {
-              lrgs(r)._def = 0;
+            bool remove = true;
+            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) {
+                  remove = false;
+                  break;
+                }
+              }
             }
-            n->disconnect_inputs(NULL, C);
-            _cfg.unmap_node_from_block(n);
-            n->replace_by(C->top());
-            // Since yanking a Node from block, high pressure moves up one
-            hrp_index[0]--;
-            hrp_index[1]--;
-            continue;
+            if (remove) {
+              block->remove_node(j - 1);
+              if (lrgs(r)._def == n) {
+                lrgs(r)._def = 0;
+              }
+              n->disconnect_inputs(NULL, C);
+              _cfg.unmap_node_from_block(n);
+              n->replace_by(C->top());
+              // Since yanking a Node from block, high pressure moves up one
+              hrp_index[0]--;
+              hrp_index[1]--;
+              continue;
+            }
           }
 
           // Fat-projections kill many registers which cannot be used to