LinkedUndirectedGraph.create();
Scope scope = t.getScope();
// First create a node for each non-escaped variable.
for (Iterator<Var> i = scope.getVars(); i.hasNext();) {
Var v = i.next();
if (!escaped.contains(v)) {
// TODO(user): In theory, we CAN coalesce function names just like
// any variables. Our Liveness analysis captures this just like it as
// described in the specification. However, we saw some zipped and
// and unzipped size increase after this. We are not totally sure why
// that is but, for now, we will respect the dead functions and not play
// around with it.
if (!v.getParentNode().isFunction()) {
interferenceGraph.createNode(v);
}
}
}
// Go through each variable and try to connect them.
for (Iterator<Var> i1 = scope.getVars(); i1.hasNext();) {
Var v1 = i1.next();
NEXT_VAR_PAIR:
for (Iterator<Var> i2 = scope.getVars(); i2.hasNext();) {
Var v2 = i2.next();
// Skip duplicate pairs.
if (v1.index >= v2.index) {
continue;
}
if (!interferenceGraph.hasNode(v1) ||
!interferenceGraph.hasNode(v2)) {
// Skip nodes that were not added. They are globals and escaped
// locals. Also avoid merging a variable with itself.
continue NEXT_VAR_PAIR;
}
if (v1.getParentNode().isParamList() &&
v2.getParentNode().isParamList()) {
interferenceGraph.connectIfNotFound(v1, null, v2);
continue NEXT_VAR_PAIR;
}
// Go through every CFG node in the program and look at