示例#1
0
        public HashSet <StructureNode> FindLoop()
        {
            loopNodeSet = new HashSet <StructureNode>();
            var f = new SccFinder <StructureNode>(new GraphAdapter(this), x => {}, ProcessScc);

            f.Find(interval.Header);
            return(loopNodeSet);
        }
示例#2
0
        /// <summary>
        /// Find all linear induction variables in this procedure.
        /// </summary>
        public void Find()
        {
            var sccFinder = new SccFinder <SsaIdentifier>(new SsaGraph(ssa.Identifiers), x => {}, ProcessScc);

            foreach (SsaIdentifier sid in ssa.Identifiers)
            {
                sccFinder.Find(sid);
            }
        }
示例#3
0
        public void UntangleProcedures2()
        {
            eventListener.ShowStatus("Eliminating intra-block dead registers.");
            IntraBlockDeadRegisters.Apply(program);

            var sscf = new SccFinder <Procedure>(new ProcedureGraph(program), UntangleProcedureScc);

            foreach (var procedure in program.Procedures.Values)
            {
                sscf.Find(procedure);
            }
        }
示例#4
0
        // EXPERIMENTAL - consult uxmal before using
        /// <summary>
        /// Analyizes the procedures of a program by finding all strongly
        /// connected components (SCCs) and processing the SCCs one by one.
        /// </summary>
        public void AnalyzeProgram2()
        {
            var usb = new UserSignatureBuilder(program);

            usb.BuildSignatures();

            var sscf = new SccFinder <Procedure>(new ProcedureGraph(program), UntangleProcedureScc);

            foreach (var procedure in program.Procedures.Values)
            {
                sscf.Find(procedure);
            }
        }
        private void RunTest()
        {
            this.program  = builder.BuildProgram();
            this.dataFlow = new ProgramDataFlow(program);
            var sscf = new SccFinder <Procedure>(new ProcedureGraph(program), ProcessScc);

            foreach (var procedure in program.Procedures.Values)
            {
                sscf.Find(procedure);
            }
            var sbActual = new StringBuilder();
            var sw       = new StringWriter();

            foreach (var procedure in program.Procedures.Values)
            {
                var flow = dataFlow[procedure];
                sw.WriteLine("== {0} ====", procedure.Name);
                sw.Write("Preserved: ");
                sw.WriteLine(string.Join(",", flow.Preserved.OrderBy(p => p.ToString())));
                sw.Write("Trashed: ");
                sw.WriteLine(string.Join(",", flow.Trashed.OrderBy(p => p.ToString())));
                if (flow.Constants.Count > 0)
                {
                    sw.Write("Constants: ");
                    sw.Write(string.Join(
                                 ",",
                                 flow.Constants
                                 .OrderBy(kv => kv.Key.ToString())
                                 .Select(kv => string.Format(
                                             "{0}:{1}", kv.Key, kv.Value))));
                }
                sw.WriteLine();
            }
            var sExp    = sbExpected.ToString();
            var sActual = sw.ToString();

            if (sActual != sExp)
            {
                foreach (var proc in program.Procedures.Values)
                {
                    Debug.Print("------");
                    proc.Dump(true);
                }
                Debug.WriteLine(sActual);
                Assert.AreEqual(sExp, sActual);
            }
        }
示例#6
0
        private List <Procedure> ProceduresInSccOrder(Program program)
        {
            var list = new List <Procedure>();

            void CollectScc(IList <Procedure> sccProcs)
            {
                list.AddRange(sccProcs);
            }

            var sscf = new SccFinder <Procedure>(new ProcedureGraph(program), CollectScc);

            foreach (var procedure in program.Procedures.Values)
            {
                sscf.Find(procedure);
            }
            return(list);
        }
示例#7
0
        public ICollection <StructureNode> FindInfiniteLoops(DirectedGraph <StructureNode> graph, StructureNode entry)
        {
            List <StructureNode>      infiniteLoopHeaders = new List <StructureNode>();
            SccFinder <StructureNode> finder = new SccFinder <StructureNode>(graph, delegate(IList <StructureNode> scc)
            {
                if (!IsInfiniteLoop(graph, scc))
                {
                    return;
                }

                var header = FindNodeWithHighestPostOrderNumber(scc);
                foreach (StructureNode tail in graph.Predecessors(header))
                {
                    if (scc.Contains(tail))
                    {
                        infiniteLoopHeaders.Add(tail);
                    }
                }
            });

            finder.Find(entry);
            return(infiniteLoopHeaders);
        }
示例#8
0
        public void UntangleProcedures2()
        {
            eventListener.ShowStatus("Eliminating intra-block dead registers.");
            IntraBlockDeadRegisters.Apply(program);

            var sscf = new SccFinder<Procedure>(new ProcedureGraph(program), UntangleProcedureScc);
            foreach (var procedure in program.Procedures.Values)
            {
                sscf.Find(procedure);
            }
        }
示例#9
0
        // EXPERIMENTAL - consult uxmal before using
        /// <summary>
        /// Analyizes the procedures of a program by finding all strongly 
        /// connected components (SCCs) and processing the SCCs one by one.
        /// </summary>
        public void AnalyzeProgram2()
        {
            var usb = new UserSignatureBuilder(program);
            usb.BuildSignatures();

            var sscf = new SccFinder<Procedure>(new ProcedureGraph(program), UntangleProcedureScc);
            foreach (var procedure in program.Procedures.Values)
            {
                sscf.Find(procedure);
            }
        }