Beispiel #1
0
 private static bool TryGetExitBlock(
     SCCs.SCC scc,
     out BasicBlock exitBlock)
 {
     exitBlock = null;
     foreach (var node in scc)
     {
         foreach (var succ in node.Successors)
         {
             BasicBlock succBlock = succ.Block;
             if (!scc.Contains(succBlock))
             {
                 if (exitBlock != null && exitBlock != succBlock)
                 {
                     return(false);
                 }
                 exitBlock = succBlock;
             }
         }
     }
     return(exitBlock != null);
 }
Beispiel #2
0
        private static bool TryGetEntryBlock(
            SCCs.SCC scc,
            out BasicBlock entryPoint)
        {
            entryPoint = null;
            foreach (var node in scc)
            {
                foreach (var pred in node.Predecessors)
                {
                    if (scc.Contains(pred))
                    {
                        continue;
                    }

                    // Multiple loop entry points
                    if (entryPoint != null & entryPoint != pred.Block)
                    {
                        return(false);
                    }
                    entryPoint = pred.Block;
                }
            }
            return(true);
        }