Skip to content

Commit d5627fd

Browse files
authored
Merge pull request #1040 from jbj/dominanceFrontier-iterated
C++: Implement dominanceFrontier with recursion
2 parents a3f452b + d310338 commit d5627fd

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/SSAUtils.qll

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ import semmle.code.cpp.controlflow.SSA // must be imported for proper caching of
44
import semmle.code.cpp.rangeanalysis.RangeSSA // must be imported for proper caching of SSAHelper
55

66
/* The dominance frontier of a block `x` is the set of all blocks `w` such that
7-
* `x` dominates a predecessor of `w` but does not strictly dominate `w`. */
8-
pragma[noinline]
7+
* `x` dominates a predecessor of `w` but does not strictly dominate `w`.
8+
*
9+
* This implementation is equivalent to:
10+
*
11+
* bbDominates(x, w.getAPredecessor()) and not bbStrictlyDominates(x, w)
12+
*/
913
private predicate dominanceFrontier(BasicBlock x, BasicBlock w) {
10-
bbDominates(x, w.getAPredecessor()) and not bbStrictlyDominates(x, w)
14+
x = w.getAPredecessor() and not bbIDominates(x, w)
15+
or
16+
exists(BasicBlock prev | dominanceFrontier(prev, w) |
17+
bbIDominates(x, prev) and
18+
not bbIDominates(x, w)
19+
)
1120
}
1221

1322
/**

0 commit comments

Comments
 (0)