lack RPO basicBlocks traversal may cause undeciable problem for `dominator` algorithm implementation
shenjunjiekoda opened this issue · comments
We may need RPO traversal utility for BasicBlocks
In the DominanceFinder
in soot.core.graph
,
// we're locked into providing a List<BasicBlock<?>>, not a List<? extends BasicBlock<?>>, so
// we'll use the block iterator directly (which provides this type) rather than
// #getBlocksSorted.
blocks =
StreamSupport.stream(
Spliterators.spliteratorUnknownSize(
blockGraph.getBlockIterator(), Spliterator.ORDERED),
false)
.collect(Collectors.toList());
I find that the sorted for Blocks ued by dominator calculation might not be reverse post order (may be the pseudo topological order now ), which may cause incorrectness.
The author of this implementation mentioned that he used the algorithm proposed in this paper
https://web.cse.ohio-state.edu/~rountev.1/788/papers/cooper-spe01.pdf
* @see <a
* href="https://www.researchgate.net/publication/2569680_A_Simple_Fast_Dominance_Algorithm">
* https://www.researchgate.net/publication/2569680_A_Simple_Fast_Dominance_Algorithm </a>
I found that the following algorithm, which use Reverse post order
blocks traversal and use post order of 2 blocks to decide the result intersect
.
![dom_algo](https://private-user-images.githubusercontent.com/52376093/322686664-dd8a8323-0328-4553-8ee5-a1bcf7964a93.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxMDUyOTQsIm5iZiI6MTcyMDEwNDk5NCwicGF0aCI6Ii81MjM3NjA5My8zMjI2ODY2NjQtZGQ4YTgzMjMtMDMyOC00NTUzLThlZTUtYTFiY2Y3OTY0YTkzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA0VDE0NTYzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE2MTc0MTQzNDE4OWIzNTMzODY0YWY5YmJjYjFkNjA1YzlhYjM0NDA1NGFlMzFmM2U2YTRlZTYxZmRkMGY5YzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.F1sN7sgAS1l88iZyqo1NtDK5ZKTGULifuoX3JiAuXr4)
Shall we add a implementation for RPO and PO which may used for dom and post dom calculation?
Dear maintainer, hello! If you feel the issue does indeed exist, I'd like to try contributing code to fix it later.
Hi @shenjunjiekoda,
we are pleased it if you like to contribute the proposed additions!