Skip to content

Fix two issues with DominanceFinder#744

Merged
kadirayk merged 4 commits intosoot-oss:developfrom
Liam-DeVoe:fix-dom-finder
Nov 8, 2023
Merged

Fix two issues with DominanceFinder#744
kadirayk merged 4 commits intosoot-oss:developfrom
Liam-DeVoe:fix-dom-finder

Conversation

@Liam-DeVoe
Copy link
Copy Markdown
Contributor

First off: apologies for bundling two fixes with this PR. I would have submitted them separately, but the test I added runs into both issues, and so would fail on any PR which included only a fix for one. I've done the next best thing and split the fixes into commits (c07888e and b505857). However, I'm happy to split these into PRs on request.

c07888e: use .equals to compare to starting stmt

This closes #586 by using .equals for comparison instead of ==.

b505857: use correct reverse postorder iteration for dominance finder

While investigating #586, I found that DominanceFinder was not computing the correct dominators for the test I added. I think the reasons for this are two-fold:

  • To start, on master, DominanceFinder#getIdxToBlock and DominanceFinder#getBlockToIdx are not inverses (git checkout c07888eea and running testBlockToIdxInverse confirms this). This causes dominance indexes to become mixed up internally and the wrong dominator to be returned.
  • Even if this is fixed in a simple way, I don't believe that iterating over blockGraph.getBlocks() to compute immediate dominators is correct. The algorithm referenced requires that blocks are iterated over in reverse postorder. blockGraph.getBlocks()'s xmldoc indicates that its ordering is not only not reverse postorder, but is not necessarily in any deterministic order.

I've chosen to iterate over blockGraph.getBlockIterator() instead, which fixes the first issue by using blockGraph.getBlockIterator() as the ordered source of truth for nodes (and building the backwards blockToIdx map straight from it). This also fixes the second issue, as blockGraph.getBlockIterator() seems to provide the nodes in reverse postorder, as required. However, I'm not sure if this is an invariant I can rely on - let me know if it's not.

I also fixed a dead pdf link along the way.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5d038b1) 63.97% compared to head (db69a56) 64.42%.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #744      +/-   ##
=============================================
+ Coverage      63.97%   64.42%   +0.44%     
- Complexity      3424     3447      +23     
=============================================
  Files            317      317              
  Lines          15408    15408              
  Branches        2612     2611       -1     
=============================================
+ Hits            9858     9926      +68     
+ Misses          4640     4567      -73     
- Partials         910      915       +5     
Files Coverage Δ
...c/main/java/sootup/core/graph/DominanceFinder.java 80.00% <100.00%> (+80.00%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Member

@kadirayk kadirayk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! 👍

@kadirayk kadirayk merged commit 14227f1 into soot-oss:develop Nov 8, 2023
@Liam-DeVoe Liam-DeVoe deleted the fix-dom-finder branch November 8, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dominance Finder Out of Bounds Error

2 participants