Mercurial > hg > graal-compiler
changeset 23133:a421f21a0054
Make sure leaf nodes have been GVN'ed
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 02 Dec 2015 11:06:05 -0800 |
parents | c8eb711096d2 |
children | f0dad49ca665 |
files | graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java |
diffstat | 2 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Tue Dec 01 08:46:50 2015 -0800 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Wed Dec 02 11:06:05 2015 -0800 @@ -242,9 +242,23 @@ return true; } } + assert assertLeafGVN(node, nodeClass); return false; } + /** + * Ensure that leaf nodes have already been GVN'ed. This is normally handled automatically + * but it's possible to add nodes to the graph with looking for duplicates and it's the + * responsibility of code that does that to clean it up. + */ + private boolean assertLeafGVN(Node node, NodeClass<?> nodeClass) { + if (node.isAlive() && nodeClass.valueNumberable() && nodeClass.isLeafNode()) { + Node newNode = node.graph().findDuplicate(node); + return (newNode == null || newNode == node); + } + return true; + } + private AutoCloseable getCanonicalizeableContractAssertion(Node node) { boolean needsAssertion = false; assert (needsAssertion = true) == true;
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java Tue Dec 01 08:46:50 2015 -0800 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java Wed Dec 02 11:06:05 2015 -0800 @@ -122,6 +122,27 @@ } protected void postIteration(final StructuredGraph graph, final PhaseContextT context, Set<Node> changedNodes) { + /* + * The nodes were added without uniqueing them first so GVN the leaf nodes now. The normal + * CanonicalizerPhase will GVN non-leaf value numberable nodes. + */ + for (Node node : changedNodes) { + if (node.isAlive() && node.getNodeClass().valueNumberable() && node.getNodeClass().isLeafNode()) { + Node duplicate = graph.findDuplicate(node); + if (duplicate != node) { + if (duplicate == null) { + /* + * There's no version of this constant in the leaf node cache so create a + * copy to add it to the table. + */ + duplicate = node.copyWithInputs(); + assert duplicate == graph.findDuplicate(duplicate); + } + node.replaceAtUsages(duplicate); + node.safeDelete(); + } + } + } if (canonicalizer != null) { canonicalizer.applyIncremental(graph, context, changedNodes); }