/// <summary> /// Does not quite work as it recursively inlines everything /// </summary> /// <param name="prog"></param> /// <param name="impl"></param> /// <param name="bound"></param> /// <param name="recursionDepth"></param> /// <param name="callGraph"></param> /// <param name="inlineOpt"></param> public static void InlineUptoDepth(Program prog, Implementation impl, int bound, int recursionDepth, Graph <Procedure> callGraph, CommandLineOptions.Inlining inlineOpt) { CommandLineOptions.Clo.ProcedureInlining = inlineOpt; //inline and then use spec, no unsoundness var inlineProcs = AddInlineAttributesUptoDepth(prog, impl, bound, recursionDepth, callGraph); Inline(prog); inlineProcs.Iter(x => { x.Attributes = x.Attributes.Next; }); //remove any inline attributes }
protected void Inline() { //Copied from Boogie\Houdini.cs if (CommandLineOptions.Clo.InlineDepth <= 0) { return; } //foreach (Implementation impl in callGraph.Nodes) //{ // InlineEnsuresVisitor inlineEnsuresVisitor = new InlineEnsuresVisitor(); // inlineEnsuresVisitor.Visit(impl); //} foreach (Implementation impl in callGraph.Nodes) { impl.OriginalBlocks = impl.Blocks; impl.OriginalLocVars = impl.LocVars; } foreach (Implementation impl in callGraph.Nodes) { CommandLineOptions.Inlining savedOption = CommandLineOptions.Clo.ProcedureInlining; CommandLineOptions.Clo.ProcedureInlining = CommandLineOptions.Inlining.Spec; Inliner.ProcessImplementationForHoudini(program, impl); CommandLineOptions.Clo.ProcedureInlining = savedOption; } foreach (Implementation impl in callGraph.Nodes) { impl.OriginalBlocks = null; impl.OriginalLocVars = null; } Graph <Implementation> oldCallGraph = callGraph; callGraph = new Graph <Implementation>(); foreach (Implementation impl in oldCallGraph.Nodes) { callGraph.AddSource(impl); } foreach (Tuple <Implementation, Implementation> edge in oldCallGraph.Edges) { callGraph.AddEdge(edge.Item1, edge.Item2); } int count = CommandLineOptions.Clo.InlineDepth; while (count > 0) { foreach (Implementation impl in oldCallGraph.Nodes) { List <Implementation> newNodes = new List <Implementation>(); foreach (Implementation succ in callGraph.Successors(impl)) { newNodes.AddRange(oldCallGraph.Successors(succ)); } foreach (Implementation newNode in newNodes) { callGraph.AddEdge(impl, newNode); } } count--; } }