summaryrefslogtreecommitdiff
path: root/Source/Graph
diff options
context:
space:
mode:
authorGravatar qadeer <unknown>2010-09-01 15:25:06 +0000
committerGravatar qadeer <unknown>2010-09-01 15:25:06 +0000
commit6a71d5d0c7347da955f2c5e526bd9f2dcf908429 (patch)
tree1bcca91fb5fd968ba23f55424541162ff843bffb /Source/Graph
parentca50aef90076b154b2748d1bf5a8f046452a2aa3 (diff)
fixed bug in extract loops by ensuring that loop extraction is done in nesting order
Diffstat (limited to 'Source/Graph')
-rw-r--r--Source/Graph/Graph.cs19
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/Graph/Graph.cs b/Source/Graph/Graph.cs
index 768f499e..6bfd5c34 100644
--- a/Source/Graph/Graph.cs
+++ b/Source/Graph/Graph.cs
@@ -761,7 +761,24 @@ namespace Graphing {
return;
}
-
+ public IEnumerable<Node> SortHeadersByDominance()
+ {
+ Graph<Node> dag = new Graph<Node>();
+ foreach (Node b in headers)
+ {
+ dag.AddSource(b);
+ foreach (Node c in headers)
+ {
+ if (b.Equals(c)) continue;
+ if (DominatorMap.DominatedBy(b, c))
+ {
+ Debug.Assert(!DominatorMap.DominatedBy(c, b));
+ dag.AddEdge(b, c);
+ }
+ }
+ }
+ return dag.TopologicalSort();
+ }
} // end: class Graph
public class GraphProgram {