use of org.graalvm.compiler.nodes.cfg.HIRLoop in project graal by oracle.
the class FloatingReadPhase method run.
@Override
@SuppressWarnings("try")
protected void run(StructuredGraph graph) {
EconomicMap<LoopBeginNode, EconomicSet<LocationIdentity>> modifiedInLoops = null;
if (graph.hasLoops()) {
modifiedInLoops = EconomicMap.create(Equivalence.IDENTITY);
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, false, false);
for (Loop<?> l : cfg.getLoops()) {
HIRLoop loop = (HIRLoop) l;
processLoop(loop, modifiedInLoops);
}
}
HashSetNodeEventListener listener = new HashSetNodeEventListener(EnumSet.of(NODE_ADDED, ZERO_USAGES));
try (NodeEventScope nes = graph.trackNodeEvents(listener)) {
ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, createFloatingReads, createMemoryMapNodes), graph.start(), new MemoryMapImpl(graph.start()));
}
for (Node n : removeExternallyUsedNodes(listener.getNodes())) {
if (n.isAlive() && n instanceof FloatingNode) {
n.replaceAtUsages(null);
GraphUtil.killWithUnusedFloatingInputs(n);
}
}
if (createFloatingReads) {
assert !graph.isAfterFloatingReadPhase();
graph.setAfterFloatingReadPhase(true);
}
}
use of org.graalvm.compiler.nodes.cfg.HIRLoop in project graal by oracle.
the class FloatingReadPhase method processLoop.
private EconomicSet<LocationIdentity> processLoop(HIRLoop loop, EconomicMap<LoopBeginNode, EconomicSet<LocationIdentity>> modifiedInLoops) {
LoopBeginNode loopBegin = (LoopBeginNode) loop.getHeader().getBeginNode();
EconomicSet<LocationIdentity> result = modifiedInLoops.get(loopBegin);
if (result != null) {
return result;
}
result = EconomicSet.create(Equivalence.DEFAULT);
for (Loop<Block> inner : loop.getChildren()) {
result.addAll(processLoop((HIRLoop) inner, modifiedInLoops));
}
for (Block b : loop.getBlocks()) {
if (b.getLoop() == loop) {
processBlock(b, result);
}
}
modifiedInLoops.put(loopBegin, result);
return result;
}
Aggregations