start of new file
[IRC.git] / Robust / src / Analysis / Prefetch / LoopExit.java
index d116741d92f13180160a0f7ffcd2f33583c0ea99..2b1099b6dbd10d16b067bd215c966760c1c05cd8 100644 (file)
@@ -40,6 +40,7 @@ public class LoopExit {
        
        while(!nodeset.isEmpty()) {
            FlatNode fn=nodeset.iterator().next();
+           nodeset.remove(fn);
            if (fn.kind()==FKind.FlatCondBranch&&((FlatCondBranch)fn).isLoopBranch()) {
                FlatCondBranch fcb=(FlatCondBranch)fn;
                loopbranchset.add(fcb);
@@ -49,7 +50,8 @@ public class LoopExit {
                propagateset(nodeset, table, fcb, fcb.getNext(1), null); 
                loopbranchset.add(fcb);
            } else if (fn.kind()==FKind.FlatReturnNode) {
-               exitset.addAll(table.get(fn));
+               if (table.containsKey(fn))
+                   exitset.addAll(table.get(fn));
            } else {
                for(int i=0;i<fn.numNext();i++)
                    propagateset(nodeset, table, fn, fn.getNext(i), null); 
@@ -64,8 +66,12 @@ public class LoopExit {
        if (table.containsKey(fn)) {
            if (!table.containsKey(fnnext))
                table.put(fnnext, new HashSet<FlatCondBranch>());
-           if(!table.get(fnnext).containsAll(table.get(fn))) {
-               table.get(fnnext).addAll(table.get(fn));
+           HashSet<FlatCondBranch> toadd=new HashSet<FlatCondBranch>();
+           toadd.addAll(table.get(fn));
+           if (toadd.contains(fnnext)) //can't propagate back to node
+               toadd.remove(fnnext);
+           if(!table.get(fnnext).containsAll(toadd)) {
+               table.get(fnnext).addAll(toadd);
                enqueuechange=true;
            }
        }