//
for (int w = 0; w < size; w++) {
header[w] = 0;
type[w] = BasicBlockClass.BB_NONHEADER;
BasicBlock nodeW = nodes[w].getBb();
if (nodeW == null) {
type[w] = BasicBlockClass.BB_DEAD;
continue; // dead BB
}
if (nodeW.getNumPred() > 0) {
for (BasicBlock nodeV : nodeW.getInEdges()) {
int v = number.get(nodeV);
if (v == UNVISITED) {
continue; // dead node
}
if (isAncestor(w, v, last)) {
backPreds.get(w).add(v);
} else {
nonBackPreds.get(w).add(v);
}
}
}
}
// Start node is root of all other loops.
header[0] = 0;
// Step c:
//
// The outer loop, unchanged from Tarjan. It does nothing except
// for those nodes which are the destinations of backedges.
// For a header node w, we chase backward from the sources of the
// backedges adding nodes to the set P, representing the body of
// the loop headed by w.
//
// By running through the nodes in reverse of the DFST preorder,
// we ensure that inner loop headers will be processed before the
// headers for surrounding loops.
//
for (int w = size - 1; w >= 0; w--) {
// this is 'P' in Havlak's paper
LinkedList<UnionFindNode> nodePool = new LinkedList<UnionFindNode>();
BasicBlock nodeW = nodes[w].getBb();
if (nodeW == null) {
continue; // dead BB
}
// Step d: