soot-oss / SootUp

A new version of Soot with a completely overhauled architecture
https://soot-oss.github.io/SootUp/
GNU Lesser General Public License v2.1
546 stars 66 forks source link

update implementation for `BackwardsStmtGraph` and add `PostDominanceFinder` utility #921

Closed shenjunjiekoda closed 2 months ago

shenjunjiekoda commented 2 months ago

update the implementation for BackwardsStmtGraph in sootup.core.graph

before in DominanceFinder.java:

List<BasicBlock<?>> preds = new ArrayList<>(block.getPredecessors());

after in DominanceFinder.java:

List<BasicBlock<?>> preds = new ArrayList<>(blockGraph.predecessors(block));

Apply this change , we can create PostDominaceFinder as a wrapper of DominanceFinder directly through use backwardStmtGraph as internal backingGraph. To implement this, I add successors/predecessors api in StmtGraph and its subclasses which use block as param instead of dependending on the BasicBlock api: getPredecessors/getSuccessors.

public class PostDominanceFinder extends DominanceFinder {

  public PostDominanceFinder(StmtGraph<?> blockGraph) {
    super(new BackwardsStmtGraph(blockGraph));
  }
}

Thank you for considering this update!