diff options
author | qadeer <unknown> | 2010-09-01 15:25:06 +0000 |
---|---|---|
committer | qadeer <unknown> | 2010-09-01 15:25:06 +0000 |
commit | 6a71d5d0c7347da955f2c5e526bd9f2dcf908429 (patch) | |
tree | 1bcca91fb5fd968ba23f55424541162ff843bffb /Source/Graph/Graph.cs | |
parent | ca50aef90076b154b2748d1bf5a8f046452a2aa3 (diff) |
fixed bug in extract loops by ensuring that loop extraction is done in nesting order
Diffstat (limited to 'Source/Graph/Graph.cs')
-rw-r--r-- | Source/Graph/Graph.cs | 19 |
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 {
|