Example #1
0
 private bool IsBackEdge(Region a, Region b)
 {
     return doms.DominatesStrictly(b, a);
 }
Example #2
0
 private Region Dfs(Region n)
 {
     Debug.Print("DFS: visiting node {0}", n.Block.Name);
     if (!IsCyclic(n))
     {
         return MatchAcyclic(n);
     }
     else
     {
         return MatchCyclic(n);
     }
 }
Example #3
0
 private bool IsCyclic(Region n)
 {
     return regionGraph.Predecessors(n).Any(pred => pred == n || IsBackEdge(pred, n));
 }
Example #4
0
 private DominatorGraph<Region> BuildPostDoms()
 {
     var revGraph = new ReverseGraph(regionGraph);
     var exitNode = new Region(new Block(proc, "DummyExitBlock")) { Type = RegionType.Tail };
     revGraph.Nodes.Add(exitNode);
     var tailRegions = regionGraph.Nodes.Where(n => n.Type == RegionType.Tail);
     foreach (var r in tailRegions)
     {
         revGraph.AddEdge(exitNode, r);
     }
     return new DominatorGraph<Region>(revGraph, exitNode);
 }