changeset 7445:2aa1a6c41461

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
author kvn
date Fri, 21 Nov 2014 17:17:41 -0800
parents 9e340d8c1aec
children 14ecb6b68f85
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	Fri Nov 21 17:28:29 2014 +0300
+++ b/src/share/vm/opto/ifg.cpp	Fri Nov 21 17:17:41 2014 -0800
@@ -527,6 +527,22 @@
   Node* def = n->in(0);
   if (!n->is_Proj() ||
       (_lrg_map.live_range_id(def) && !liveout->member(_lrg_map.live_range_id(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->remove_node(location);
     LRG& lrg = lrgs(lid);
     if (lrg._def == n) {