changeset 9696:ce80e563cd22

Remove unused read nodes.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 14 May 2013 22:10:13 -0700
parents a39e67ca883b
children 5797e0028796
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Tue May 14 23:18:00 2013 -0400
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Tue May 14 22:10:13 2013 -0700
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes.extended;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.LocationNode.LocationIdentity;
@@ -72,6 +73,10 @@
 
     public static ValueNode canonicalizeRead(ValueNode read, LocationNode location, ValueNode object, CanonicalizerTool tool) {
         MetaAccessProvider runtime = tool.runtime();
+        if (read.usages().count() == 0) {
+            // Read without usages can be savely removed.
+            return null;
+        }
         if (runtime != null && object != null && object.isConstant()) {
             if (location.getLocationIdentity() == LocationNode.FINAL_LOCATION && location instanceof ConstantLocationNode) {
                 long displacement = ((ConstantLocationNode) location).getDisplacement();