/// <summary> /// Summarizes the net effect each procedure has on registers, /// then removes trashed registers that aren't live-out. /// </summary> public List <SsaTransform> UntangleProcedures() { eventListener.ShowProgress("Rewriting procedures.", 0, program.Procedures.Count); IntraBlockDeadRegisters.Apply(program, eventListener); AdjacentBranchCollector.Transform(program, eventListener); var ssts = RewriteProceduresToSsa(); // Recreate user-defined signatures. It should prevent type // inference between user-defined parameters and other expressions var usb = new UserSignatureBuilder(program); usb.BuildSignatures(eventListener); // Discover ssaId's that are live out at each call site. // Delete all others. var uvr = new UnusedOutValuesRemover( program, ssts.Select(sst => sst.SsaState), this.flow, dynamicLinker, eventListener); uvr.Transform(); // At this point, the exit blocks contain only live out registers. // We can create signatures from that. CallRewriter.Rewrite(program.Platform, ssts, this.flow, eventListener); return(ssts); }
public static void Transform(Program program, DecompilerEventListener eventListener) { foreach (var proc in program.Procedures.Values) { if (eventListener.IsCanceled()) { return; } var abc = new AdjacentBranchCollector(proc, eventListener); abc.Transform(); } }
/// <summary> /// Finds all interprocedural register dependencies (in- and out-parameters) and /// abstracts them away by rewriting as calls. /// </summary> /// <returns>A RegisterLiveness object that summarizes the interprocedural register /// liveness analysis. This information can be used to generate SSA form. /// </returns> public void UntangleProcedures() { eventListener.ShowStatus("Eliminating intra-block dead registers."); var usb = new UserSignatureBuilder(program); usb.BuildSignatures(eventListener); CallRewriter.Rewrite(program, eventListener); IntraBlockDeadRegisters.Apply(program, eventListener); AdjacentBranchCollector.Transform(program, eventListener); eventListener.ShowStatus("Finding terminating procedures."); var term = new TerminationAnalysis(flow, eventListener); term.Analyze(program); eventListener.ShowStatus("Finding trashed registers."); var trf = new TrashedRegisterFinder(program, program.Procedures.Values, flow, eventListener); trf.Compute(); eventListener.ShowStatus("Rewriting affine expressions."); trf.RewriteBasicBlocks(); eventListener.ShowStatus("Computing register liveness."); RegisterLiveness.Compute(program, flow, eventListener); eventListener.ShowStatus("Rewriting calls."); GlobalCallRewriter.Rewrite(program, flow, eventListener); }