protected override void RunTest(Program program, TextWriter fut) { IDynamicLinker dynamicLinker = null; var listener = sc.RequireService <DecompilerEventListener>(); DataFlowAnalysis dfa = new DataFlowAnalysis(program, dynamicLinker, sc); var ssts = dfa.UntangleProcedures(); foreach (Procedure proc in program.Procedures.Values) { var sst = ssts.Single(s => s.SsaState.Procedure == proc); SsaState ssa = sst.SsaState; ConditionCodeEliminator cce = new ConditionCodeEliminator(program, ssa, listener); cce.Transform(); DeadCode.Eliminate(ssa); ValuePropagator vp = new ValuePropagator(program.SegmentMap, ssa, program.CallGraph, dynamicLinker, listener); vp.Transform(); DeadCode.Eliminate(ssa); Coalescer co = new Coalescer(ssa); co.Transform(); ssa.Write(fut); proc.Write(false, fut); fut.WriteLine(); ssa.Validate(s => { ssa.Dump(true); Assert.Fail(s); }); } }
private void Build(Procedure proc, IProcessorArchitecture arch) { var platform = new DefaultPlatform(null, arch); this.proc = proc; Aliases alias = new Aliases(proc, arch); alias.Transform(); SsaTransform sst = new SsaTransform( new ProgramDataFlow(), proc, null, proc.CreateBlockDominatorGraph(), new HashSet <RegisterStorage>()); ssa = sst.SsaState; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform); cce.Transform(); ValuePropagator vp = new ValuePropagator(arch, ssa, new FakeDecompilerEventListener()); vp.Transform(); DeadCode.Eliminate(proc, ssa); Coalescer coa = new Coalescer(proc, ssa); coa.Transform(); DeadCode.Eliminate(proc, ssa); sla = new SsaLivenessAnalysis(proc, ssa.Identifiers); sla2 = new SsaLivenessAnalysis2(proc, ssa.Identifiers); sla2.Analyze(); }
public void RunCoalescer() { var co = new Coalescer(m.Ssa); co.Transform(); m.Ssa.Validate(s => Assert.Fail(s)); }
protected override void RunTest(Program prog, TextWriter fut) { IImportResolver importResolver = null; DataFlowAnalysis dfa = new DataFlowAnalysis(prog, importResolver, new FakeDecompilerEventListener()); dfa.UntangleProcedures(); foreach (Procedure proc in prog.Procedures.Values) { Aliases alias = new Aliases(proc, prog.Architecture); alias.Transform(); SsaTransform sst = new SsaTransform(dfa.ProgramDataFlow, proc, importResolver, proc.CreateBlockDominatorGraph()); SsaState ssa = sst.SsaState; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa.Identifiers, prog.Platform); cce.Transform(); DeadCode.Eliminate(proc, ssa); ValuePropagator vp = new ValuePropagator(prog.Architecture, ssa.Identifiers, proc); vp.Transform(); DeadCode.Eliminate(proc, ssa); Coalescer co = new Coalescer(proc, ssa); co.Transform(); ssa.Write(fut); proc.Write(false, fut); fut.WriteLine(); } }
protected override void RunTest(Program program, TextWriter fut) { IImportResolver importResolver = null; var listener = new FakeDecompilerEventListener(); DataFlowAnalysis dfa = new DataFlowAnalysis(program, importResolver, listener); dfa.UntangleProcedures(); foreach (Procedure proc in program.Procedures.Values) { Aliases alias = new Aliases(proc); alias.Transform(); SsaTransform sst = new SsaTransform(dfa.ProgramDataFlow, proc, importResolver, proc.CreateBlockDominatorGraph(), new HashSet <RegisterStorage>()); SsaState ssa = sst.SsaState; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, program.Platform); cce.Transform(); DeadCode.Eliminate(proc, ssa); ValuePropagator vp = new ValuePropagator(program.SegmentMap, ssa, program.CallGraph, importResolver, listener); vp.Transform(); DeadCode.Eliminate(proc, ssa); Coalescer co = new Coalescer(proc, ssa); co.Transform(); ssa.Write(fut); proc.Write(false, fut); fut.WriteLine(); ssa.Validate(s => Assert.Fail(s)); } }
private void Build(Procedure proc, IProcessorArchitecture arch) { var platform = new DefaultPlatform(null, arch); this.proc = proc; Aliases alias = new Aliases(proc, arch); alias.Transform(); var gr = proc.CreateBlockDominatorGraph(); SsaTransform sst = new SsaTransform(new ProgramDataFlow(), proc, gr); SsaState ssa = sst.SsaState; this.ssaIds = ssa.Identifiers; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa.Identifiers, platform); cce.Transform(); DeadCode.Eliminate(proc, ssa); ValuePropagator vp = new ValuePropagator(arch, ssa.Identifiers, proc); vp.Transform(); Coalescer coa = new Coalescer(proc, ssa); coa.Transform(); DeadCode.Eliminate(proc, ssa); }
private void Build(Program program) { var eventListener = new FakeDecompilerEventListener(); var sc = new ServiceContainer(); sc.AddService <DecompilerEventListener>(eventListener); var dfa = new DataFlowAnalysis(program, null, sc); var ssts = dfa.UntangleProcedures(); foreach (Procedure proc in program.Procedures.Values) { var sst = ssts.Single(s => s.SsaState.Procedure == proc); var ssa = sst.SsaState; Coalescer coa = new Coalescer(ssa); coa.Transform(); DeadCode.Eliminate(ssa); LiveCopyInserter lci = new LiveCopyInserter(ssa); lci.Transform(); WebBuilder web = new WebBuilder(program, ssa, new Dictionary <Identifier, LinearInductionVariable>(), eventListener); web.Transform(); ssa.ConvertBack(false); } }
private void Build(Procedure proc, IProcessorArchitecture arch) { var platform = new DefaultPlatform(null, arch); this.proc = proc; Aliases alias = new Aliases(proc); alias.Transform(); var importResolver = new Mock <IImportResolver>().Object; SsaTransform sst = new SsaTransform( new ProgramDataFlow(), proc, importResolver, proc.CreateBlockDominatorGraph(), new HashSet <RegisterStorage>()); ssa = sst.SsaState; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform); cce.Transform(); var segmentMap = new SegmentMap(Address.Ptr32(0x00123400)); ValuePropagator vp = new ValuePropagator(segmentMap, ssa, new CallGraph(), importResolver, new FakeDecompilerEventListener()); vp.Transform(); DeadCode.Eliminate(proc, ssa); Coalescer coa = new Coalescer(proc, ssa); coa.Transform(); DeadCode.Eliminate(proc, ssa); sla = new SsaLivenessAnalysis(proc, ssa.Identifiers); sla2 = new SsaLivenessAnalysis2(proc, ssa.Identifiers); sla2.Analyze(); }
private void Build(Procedure proc, IProcessorArchitecture arch) { var platform = new DefaultPlatform(null, arch); var program = new Program() { Architecture = arch, Platform = platform, }; this.proc = proc; var dynamicLinker = new Mock <IDynamicLinker>().Object; var gr = proc.CreateBlockDominatorGraph(); SsaTransform sst = new SsaTransform( program, proc, new HashSet <Procedure>(), null, new ProgramDataFlow()); sst.Transform(); this.ssa = sst.SsaState; this.ssaIds = ssa.Identifiers; var listener = new FakeDecompilerEventListener(); ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform, listener); cce.Transform(); DeadCode.Eliminate(ssa); var segmentMap = new SegmentMap(Address.Ptr32(0x00400000)); ValuePropagator vp = new ValuePropagator( segmentMap, ssa, program.CallGraph, null, listener); vp.Transform(); Coalescer coa = new Coalescer(ssa); coa.Transform(); DeadCode.Eliminate(ssa); }
private void Build(Procedure proc, IProcessorArchitecture arch) { var platform = new DefaultPlatform(null, arch); var program = new Program() { Architecture = arch, Platform = platform, }; this.proc = proc; var dynamicLinker = new Mock <IDynamicLinker>().Object; var listener = new FakeDecompilerEventListener(); var sst = new SsaTransform( program, proc, new HashSet <Procedure>(), dynamicLinker, new ProgramDataFlow()); sst.Transform(); ssa = sst.SsaState; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform, listener); cce.Transform(); var segmentMap = new SegmentMap(Address.Ptr32(0x00123400)); ValuePropagator vp = new ValuePropagator(segmentMap, ssa, program.CallGraph, dynamicLinker, listener); vp.Transform(); DeadCode.Eliminate(ssa); Coalescer coa = new Coalescer(ssa); coa.Transform(); DeadCode.Eliminate(ssa); sla = new SsaLivenessAnalysis(ssa); sla2 = new SsaLivenessAnalysis2(ssa); sla2.Analyze(); }
private void Build(Program program) { var eventListener = new FakeDecompilerEventListener(); DataFlowAnalysis dfa = new DataFlowAnalysis(program, null, eventListener); dfa.UntangleProcedures(); foreach (Procedure proc in program.Procedures.Values) { Aliases alias = new Aliases(proc, program.Architecture); alias.Transform(); var gr = proc.CreateBlockDominatorGraph(); SsaTransform sst = new SsaTransform(dfa.ProgramDataFlow, proc, null, gr, new HashSet <RegisterStorage>()); SsaState ssa = sst.SsaState; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, program.Platform); cce.Transform(); DeadCode.Eliminate(proc, ssa); var vp = new ValuePropagator(program.Architecture, ssa, eventListener); vp.Transform(); DeadCode.Eliminate(proc, ssa); Coalescer coa = new Coalescer(proc, ssa); coa.Transform(); DeadCode.Eliminate(proc, ssa); LiveCopyInserter lci = new LiveCopyInserter(proc, ssa.Identifiers); lci.Transform(); WebBuilder web = new WebBuilder(proc, ssa.Identifiers, new Dictionary <Identifier, LinearInductionVariable>()); web.Transform(); ssa.ConvertBack(false); } }
private void Build(Procedure proc, IProcessorArchitecture arch) { var platform = new DefaultPlatform(null, arch); this.proc = proc; var importResolver = MockRepository.GenerateStub <IImportResolver>(); importResolver.Replay(); Aliases alias = new Aliases(proc); alias.Transform(); var gr = proc.CreateBlockDominatorGraph(); SsaTransform sst = new SsaTransform( new ProgramDataFlow(), proc, null, gr, new HashSet <RegisterStorage>()); SsaState ssa = sst.SsaState; this.ssaIds = ssa.Identifiers; ConditionCodeEliminator cce = new ConditionCodeEliminator(ssa, platform); cce.Transform(); DeadCode.Eliminate(proc, ssa); var segmentMap = new SegmentMap(Address.Ptr32(0x00400000)); ValuePropagator vp = new ValuePropagator(segmentMap, ssa, new FakeDecompilerEventListener()); vp.Transform(); Coalescer coa = new Coalescer(proc, ssa); coa.Transform(); DeadCode.Eliminate(proc, ssa); }