private Set<CallNode> compute(IProgressMonitor progress) throws CancelException { Set<CallNode> calls = HashSetFactory.make(); Set<CGNode> recursive = findRecursiveMethods(progress); Set<CGNode> loop = findLoopingMethods(progress); CallGraph cg = sdg.getCallGraph(); Graph<CGNode> inverted = GraphInverter.invert(cg); GraphReachability<CGNode, CGNode> reach = new GraphReachability<CGNode, CGNode>(inverted, new TrueFilter()); progress.subTask("Searching potential non-returning calls"); reach.solve(progress); Set<CGNode> roots = HashSetFactory.make(loop); roots.addAll(recursive); OrdinalSet<CGNode> potential = OrdinalSet.empty(); for (CGNode root : roots) { OrdinalSet<CGNode> reached = reach.getReachableSet(root); potential = OrdinalSet.unify(potential, reached); } Set<CGNode> terminating = HashSetFactory.make(); Set<CGNode> nonTerminating = HashSetFactory.make(); for (CGNode node : cg) { if (potential.contains(node)) { nonTerminating.add(node); } else { terminating.add(node); } } for (Call call : sdg.getAllCalls()) { if (nonTerminating.contains(call.callee.getCallGraphNode())) { calls.add(call.node); } } progress.done(); computeControlDependence(calls, progress); return calls; }
public CISlicer( CallGraph cg, PointerAnalysis pa, ModRef modRef, DataDependenceOptions dOptions, ControlDependenceOptions cOptions) throws IllegalArgumentException { if (dOptions == null) { throw new IllegalArgumentException("dOptions == null"); } if (dOptions.equals(DataDependenceOptions.NO_BASE_PTRS) || dOptions.equals(DataDependenceOptions.FULL)) { throw new IllegalArgumentException("Heap data dependences requested in CISlicer!"); } SDG sdg = new SDG(cg, pa, modRef, dOptions, cOptions, null); Map<Statement, Set<PointerKey>> mod = scanForMod(sdg, pa, modRef); Map<Statement, Set<PointerKey>> ref = scanForRef(sdg, pa, modRef); depGraph = GraphInverter.invert(new CISDG(sdg, mod, ref)); }
public CISlicer(final SDG sdg, final PointerAnalysis pa, final ModRef modRef) { Map<Statement, Set<PointerKey>> mod = scanForMod(sdg, pa, modRef); Map<Statement, Set<PointerKey>> ref = scanForRef(sdg, pa, modRef); depGraph = GraphInverter.invert(new CISDG(sdg, mod, ref)); }