Skip to content

Commit cd7ba17

Browse files
committed
C++: iterated dominance frontier algorithm for IR
Use the iterated dominance frontier algorithm to speed up dominance frontier calculations. The implementation is copied from d310338. Before this change, the SSA calculations for unaliased and aliased SSA used 169.9 seconds in total on these predicates: 7:Dominance::getDominanceFrontier#2#ff .. 49s 7:Dominance::blockDominates#2#ff ........ 47.5s 8:Dominance::getDominanceFrontier#ff .... 44.4s 8:Dominance::blockDominates#ff .......... 29s After this change, the above predicates are replaced by two copies of `getDominanceFrontier`, each of which takes less than a second.
1 parent c112a4d commit cd7ba17

File tree

2 files changed

+12
-10
lines changed
  • cpp/ql/src/semmle/code/cpp/ir/implementation

2 files changed

+12
-10
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/reachability/Dominance.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ predicate blockDominates(Graph::Block dominator, Graph::Block block) {
1111
blockStrictlyDominates(dominator, block) or dominator = block
1212
}
1313

14-
pragma[noinline]
1514
Graph::Block getDominanceFrontier(Graph::Block dominator) {
16-
exists(Graph::Block pred |
17-
Graph::blockSuccessor(pred, result) and
18-
blockDominates(dominator, pred) and
19-
not blockStrictlyDominates(dominator, result)
15+
Graph::blockSuccessor(dominator, result) and
16+
not blockImmediatelyDominates(dominator, result)
17+
or
18+
exists(Graph::Block prev | result = getDominanceFrontier(prev) |
19+
blockImmediatelyDominates(dominator, prev) and
20+
not blockImmediatelyDominates(dominator, result)
2021
)
2122
}

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/reachability/Dominance.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ predicate blockDominates(Graph::Block dominator, Graph::Block block) {
1111
blockStrictlyDominates(dominator, block) or dominator = block
1212
}
1313

14-
pragma[noinline]
1514
Graph::Block getDominanceFrontier(Graph::Block dominator) {
16-
exists(Graph::Block pred |
17-
Graph::blockSuccessor(pred, result) and
18-
blockDominates(dominator, pred) and
19-
not blockStrictlyDominates(dominator, result)
15+
Graph::blockSuccessor(dominator, result) and
16+
not blockImmediatelyDominates(dominator, result)
17+
or
18+
exists(Graph::Block prev | result = getDominanceFrontier(prev) |
19+
blockImmediatelyDominates(dominator, prev) and
20+
not blockImmediatelyDominates(dominator, result)
2021
)
2122
}

0 commit comments

Comments
 (0)