From 6a71d5d0c7347da955f2c5e526bd9f2dcf908429 Mon Sep 17 00:00:00 2001 From: qadeer Date: Wed, 1 Sep 2010 15:25:06 +0000 Subject: fixed bug in extract loops by ensuring that loop extraction is done in nesting order --- Source/Graph/Graph.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'Source/Graph') 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 SortHeadersByDominance() + { + Graph dag = new Graph(); + 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 { -- cgit v1.2.3