/// <summary> /// Removes unused, non-effectful instructions and basic block /// parameters from a flow graph. /// </summary> /// <param name="graph">The flow graph to transform.</param> /// <returns>A transformed flow graph.</returns> public override FlowGraph Apply(FlowGraph graph) { // This transform simply builds a set of live values and // then deletes everything that's not. // Compute the live values. var liveValues = ComputeLiveValues(graph); // Compute the set of dead values. var deadValues = new HashSet <ValueTag>(graph.ValueTags); deadValues.ExceptWith(liveValues); // Delete everything that's not live. return(graph.RemoveDefinitions(deadValues)); }