Example #1
0
        public void Pdg_PostdominateLoop()
        {
            ProcedureBuilder m = new ProcedureBuilder();

            m.Jump("test");
            m.Label("test");
            m.BranchIf(m.LocalBool("f"), "done");
            m.Label("body");
            m.Store(m.Int32(30), m.Int32(0));
            m.Jump("test");
            m.Label("done");
            m.Return();

            FindPostDominators(m);
            string sExp =
                "body (4): idom test (3)" + nl +
                "done (5): idom ProcedureBuilder_exit (6)" + nl +
                "l1 (2): idom test (3)" + nl +
                "ProcedureBuilder_entry (1): idom l1 (2)" + nl +
                "ProcedureBuilder_exit (6): idom " + nl +
                "test (3): idom done (5)" + nl;

            Console.WriteLine(sw.ToString());
            Assert.AreEqual(sExp, sw.ToString());
        }