HashMap<AllocNode, MySet<Edge>> backMap;
MySet<Edge> strongUpdateSet;
+ public void check() {
+ for(Map.Entry<AllocNode, MySet<Edge>> entry:nodeMap.entrySet()) {
+ AllocNode node=entry.getKey();
+ for(Edge e:entry.getValue())
+ if (e.src!=node)
+ throw new Error();
+ }
+ for(Map.Entry<TempDescriptor, MySet<Edge>> entry:varMap.entrySet()) {
+ TempDescriptor tmp=entry.getKey();
+ for(Edge e:entry.getValue())
+ if (e.srcvar!=tmp)
+ throw new Error();
+ }
+ }
+
/* Need this information for mapping in callee results */
MySet<Edge> reachEdge;
HashSet<AllocNode> reachNode;
}
}
-
-
public MySet<Edge> getEdges(TempDescriptor tmp) {
if (varMap.containsKey(tmp))
return varMap.get(tmp);
else return emptySet;
}
- public static MySet<Edge> emptySet=new MySet<Edge>();
+ public static MySet<Edge> emptySet=new MySet<Edge>(true);
public void printGraph(PrintWriter output, String name) {
output.println("digraph \""+name+"\" {");
if (childvarMap!=null&&childvarMap.containsKey(tmp))
continue;
for(Edge e:entry.getValue()) {
+ if (e.srcvar!=tmp)
+ throw new Error(e.srcvar +" is not equal to "+tmp);
AllocNode n=e.dst;
output.println("\t"+tmp.getSymbol()+"->"+n.getID()+";");
}
if (childNodeMap!=null&&childNodeMap.containsKey(node))
continue;
for(Edge e:entry.getValue()) {
+ if (e.src!=node)
+ throw new Error(e.src+" is not equal to "+node);
AllocNode n=e.dst;
String src=node.getID();
String dst=n.getID();
}
debugindex++;
}
-
+ for(FlatMethod fm:blockMap.keySet()) {
+ fm.printMethod();
+ }
}
/* This function builds the last delta for a basic block. It
newDelta.setBlock(new PPoint(blockvector.get(i)));
toprocess.add(newDelta);
} else {
- toprocess.add(newDelta.diffBlock(new PPoint(blockvector.get(i))));
+ Delta d=newDelta.diffBlock(new PPoint(blockvector.get(i)));
+ toprocess.add(d);
}
}
}
if (srcNodes.size()==1&&!srcNodes.iterator().next().isSummary()) {
/* Can do a strong update */
edgesToRemove=GraphManip.getEdges(graph, delta, srcNodes, fd);
- }
+ graph.strongUpdateSet=edgesToRemove;
+ } else
+ graph.strongUpdateSet=new MySet<Edge>();
/* Update diff */
updateHeapDelta(graph, delta, edgesToAdd, edgesToRemove);
applyDiffs(graph, delta);
MySet<Edge> edgesToRemove=null;
if (newSrcNodes.size()!=0) {
- if (srcNodes.size()==1&&!srcNodes.iterator().next().isSummary()) {
+ if (srcNodes.size()>1&&!srcNodes.iterator().next().isSummary()) {
/* Need to undo strong update */
if (graph.strongUpdateSet!=null) {
edgesToAdd.addAll(graph.strongUpdateSet);
- graph.strongUpdateSet.clear();
+ graph.strongUpdateSet=null; //Prevent future strong updates
}
- } else if (srcNodes.size()==0&&newSrcNodes.size()==1&&!newSrcNodes.iterator().next().isSummary()&&graph.strongUpdateSet==null) {
+ } else if (srcNodes.size()==1&&newSrcNodes.size()==1&&!newSrcNodes.iterator().next().isSummary()&&graph.strongUpdateSet!=null) {
edgesToRemove=GraphManip.getEdges(graph, delta, srcNodes, fd);
+ graph.strongUpdateSet.addAll(edgesToRemove);
}
edgesToAdd.addAll(GraphManip.genEdges(newSrcNodes, fd, dstNodes));
}
+ //Kill new edges
+ if (graph.strongUpdateSet!=null) {
+ MySet<Edge> otherEdgesToRemove=GraphManip.getDiffEdges(delta, srcNodes);
+ if (edgesToRemove!=null)
+ edgesToRemove.addAll(otherEdgesToRemove);
+ else
+ edgesToRemove=otherEdgesToRemove;
+ graph.strongUpdateSet.addAll(otherEdgesToRemove);
+ }
+
//Next look at new destinations
edgesToAdd.addAll(GraphManip.genEdges(srcNodes, fd, newDstNodes));
FlatReturnNode frn=(FlatReturnNode)node;
src=frn.getReturnTemp();
dst=returntmp;
- if (src==null) {
+ if (src==null||!src.getType().isPtr()) {
//This is a NOP
applyDiffs(graph, delta);
return delta;
}
if (delta.getInit()) {
HashSet<AllocNode> srcnodes=GraphManip.getNodes(graph, delta, src);
- MySet<Edge> edgesToAdd=GraphManip.genEdges(src, srcnodes);
+ MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, srcnodes);
MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
applyDiffs(graph, delta);
HashSet<AllocNode> newSrcNodes=GraphManip.getDiffNodes(delta, src);
/* Compute the union, and then the set of edges */
- MySet<Edge> edgesToAdd=GraphManip.genEdges(src, newSrcNodes);
+ MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, newSrcNodes);
/* Compute set of edges to remove */
MySet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
if (delta.getInit()) {
HashSet<AllocNode> srcnodes=GraphManip.getNodes(graph, delta, src);
HashSet<AllocNode> fdnodes=GraphManip.getNodes(graph, delta, srcnodes, fd);
- MySet<Edge> edgesToAdd=GraphManip.genEdges(src, fdnodes);
+ MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, fdnodes);
MySet<Edge> edgesToRemove=GraphManip.getEdges(graph, delta, dst);
updateVarDelta(graph, delta, dst, edgesToAdd, edgesToRemove);
applyDiffs(graph, delta);
HashSet<AllocNode> newTargets=new HashSet<AllocNode>();
newTargets.addAll(newfdnodes);
newTargets.addAll(difffdnodes);
- MySet<Edge> edgesToAdd=GraphManip.genEdges(src, newTargets);
+ MySet<Edge> edgesToAdd=GraphManip.genEdges(dst, newTargets);
/* Compute set of edges to remove */
MySet<Edge> edgesToRemove=GraphManip.getDiffEdges(delta, dst);
//Add it into the diffs
delta.varedgeadd.put(tmp, newedges);
//Remove the old edges
- delta.varedgeremove.put(tmp, graph.getEdges(tmp));
+ delta.varedgeremove.put(tmp, (MySet<Edge>) graph.getEdges(tmp).clone());
//Apply incoming diffs to graph
applyDiffs(graph, delta);
//Note that we create a single node