use of org.graalvm.compiler.nodes.MemoryProxyNode in project graal by oracle.
the class ScheduleVerification method processBlock.
@Override
protected EconomicSet<FloatingReadNode> processBlock(Block block, EconomicSet<FloatingReadNode> currentState) {
AbstractBeginNode beginNode = block.getBeginNode();
if (beginNode instanceof AbstractMergeNode) {
AbstractMergeNode abstractMergeNode = (AbstractMergeNode) beginNode;
for (PhiNode phi : abstractMergeNode.phis()) {
if (phi instanceof MemoryPhiNode) {
MemoryPhiNode memoryPhiNode = (MemoryPhiNode) phi;
addFloatingReadUsages(currentState, memoryPhiNode);
}
}
}
if (beginNode instanceof LoopExitNode) {
LoopExitNode loopExitNode = (LoopExitNode) beginNode;
for (ProxyNode proxy : loopExitNode.proxies()) {
if (proxy instanceof MemoryProxyNode) {
MemoryProxyNode memoryProxyNode = (MemoryProxyNode) proxy;
addFloatingReadUsages(currentState, memoryProxyNode);
}
}
}
for (Node n : blockToNodesMap.get(block)) {
if (n instanceof MemoryKill) {
if (n instanceof SingleMemoryKill) {
SingleMemoryKill single = (SingleMemoryKill) n;
processLocation(n, single.getKilledLocationIdentity(), currentState);
} else if (n instanceof MultiMemoryKill) {
MultiMemoryKill multi = (MultiMemoryKill) n;
for (LocationIdentity location : multi.getKilledLocationIdentities()) {
processLocation(n, location, currentState);
}
}
addFloatingReadUsages(currentState, n);
} else if (n instanceof MemoryAccess) {
addFloatingReadUsages(currentState, n);
} else if (n instanceof FloatingReadNode) {
FloatingReadNode floatingReadNode = (FloatingReadNode) n;
if (floatingReadNode.getLastLocationAccess() != null && floatingReadNode.getLocationIdentity().isMutable()) {
if (currentState.contains(floatingReadNode)) {
// Floating read was found in the state.
currentState.remove(floatingReadNode);
} else {
throw new RuntimeException("Floating read node " + n + " was not found in the state, i.e., it was killed by a memory check point before its place in the schedule. Block=" + block + ", block begin: " + block.getBeginNode() + " block loop: " + block.getLoop() + ", " + blockToNodesMap.get(block).get(0));
}
}
}
assert nodeMap.get(n) == block;
if (graph.isBeforeStage(StageFlag.VALUE_PROXY_REMOVAL) && block.getLoop() != null && !(n instanceof VirtualState)) {
for (Node usage : n.usages()) {
Node usageNode = usage;
if (usageNode instanceof PhiNode) {
PhiNode phiNode = (PhiNode) usage;
usageNode = phiNode.merge();
}
if (usageNode instanceof LoopExitNode) {
LoopExitNode loopExitNode = (LoopExitNode) usageNode;
if (loopExitNode.loopBegin() == n || loopExitNode.stateAfter() == n) {
continue;
}
}
Block usageBlock = nodeMap.get(usageNode);
if (usageBlock == null) {
if (usage instanceof FloatingNode || usage instanceof VirtualState || usage instanceof CallTargetNode) {
if (!(usage instanceof GuardNode)) {
/*
* We do not want to run the schedule behind the verification with
* dead code elimination, i.e., floating nodes without usages are
* not removed, thus we must handle the case that a floating node
* without a usage occurs here.
*/
if (nonFixedNodeTreeWithoutUsages(usage)) {
continue;
}
}
}
}
assert usageBlock != null || usage instanceof ProxyNode : "Usage " + usageNode + " of node " + n + " has no block";
Loop<Block> usageLoop = null;
if (usageNode instanceof ProxyNode) {
ProxyNode proxyNode = (ProxyNode) usageNode;
usageLoop = nodeMap.get(proxyNode.proxyPoint().loopBegin()).getLoop();
} else {
if (usageBlock.getBeginNode() instanceof LoopExitNode) {
// For nodes in the loop exit node block, we don't know for sure
// whether they are "in the loop" or not. It depends on whether
// one of their transient usages is a loop proxy node.
// For now, let's just assume those nodes are OK, i.e., "in the loop".
LoopExitNode loopExitNode = (LoopExitNode) usageBlock.getBeginNode();
usageLoop = nodeMap.get(loopExitNode.loopBegin()).getLoop();
} else {
usageLoop = usageBlock.getLoop();
}
}
assert usageLoop != null : n + ", " + nodeMap.get(n) + " / " + usageNode + ", " + nodeMap.get(usageNode);
while (usageLoop != block.getLoop() && usageLoop != null) {
usageLoop = usageLoop.getParent();
}
assert usageLoop != null : n + ", " + usageNode + ", " + usageBlock + ", " + usageBlock.getLoop() + ", " + block + ", " + block.getLoop();
}
}
}
return currentState;
}
Aggregations