Skip to content

Commit c115c68

Browse files
authored
Merge pull request #8542 from MathiasVP/public-iterated-dominance-frontier
C++: Use `iterated (post)dominance frontier` algorithm in `IRBlock`
2 parents b91914b + 8063097 commit c115c68

File tree

5 files changed

+70
-20
lines changed

5 files changed

+70
-20
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ class IRBlock extends IRBlockBase {
161161
*/
162162
pragma[noinline]
163163
final IRBlock dominanceFrontier() {
164-
this.dominates(result.getAPredecessor()) and
165-
not this.strictlyDominates(result)
164+
this.getASuccessor() = result and
165+
not this.immediatelyDominates(result)
166+
or
167+
exists(IRBlock prev | result = prev.dominanceFrontier() |
168+
this.immediatelyDominates(prev) and
169+
not this.immediatelyDominates(result)
170+
)
166171
}
167172

168173
/**
@@ -201,8 +206,13 @@ class IRBlock extends IRBlockBase {
201206
*/
202207
pragma[noinline]
203208
final IRBlock postDominanceFrontier() {
204-
this.postDominates(result.getASuccessor()) and
205-
not this.strictlyPostDominates(result)
209+
this.getAPredecessor() = result and
210+
not this.immediatelyPostDominates(result)
211+
or
212+
exists(IRBlock prev | result = prev.postDominanceFrontier() |
213+
this.immediatelyPostDominates(prev) and
214+
not this.immediatelyPostDominates(result)
215+
)
206216
}
207217

208218
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/IRBlock.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ class IRBlock extends IRBlockBase {
161161
*/
162162
pragma[noinline]
163163
final IRBlock dominanceFrontier() {
164-
this.dominates(result.getAPredecessor()) and
165-
not this.strictlyDominates(result)
164+
this.getASuccessor() = result and
165+
not this.immediatelyDominates(result)
166+
or
167+
exists(IRBlock prev | result = prev.dominanceFrontier() |
168+
this.immediatelyDominates(prev) and
169+
not this.immediatelyDominates(result)
170+
)
166171
}
167172

168173
/**
@@ -201,8 +206,13 @@ class IRBlock extends IRBlockBase {
201206
*/
202207
pragma[noinline]
203208
final IRBlock postDominanceFrontier() {
204-
this.postDominates(result.getASuccessor()) and
205-
not this.strictlyPostDominates(result)
209+
this.getAPredecessor() = result and
210+
not this.immediatelyPostDominates(result)
211+
or
212+
exists(IRBlock prev | result = prev.postDominanceFrontier() |
213+
this.immediatelyPostDominates(prev) and
214+
not this.immediatelyPostDominates(result)
215+
)
206216
}
207217

208218
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/IRBlock.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ class IRBlock extends IRBlockBase {
161161
*/
162162
pragma[noinline]
163163
final IRBlock dominanceFrontier() {
164-
this.dominates(result.getAPredecessor()) and
165-
not this.strictlyDominates(result)
164+
this.getASuccessor() = result and
165+
not this.immediatelyDominates(result)
166+
or
167+
exists(IRBlock prev | result = prev.dominanceFrontier() |
168+
this.immediatelyDominates(prev) and
169+
not this.immediatelyDominates(result)
170+
)
166171
}
167172

168173
/**
@@ -201,8 +206,13 @@ class IRBlock extends IRBlockBase {
201206
*/
202207
pragma[noinline]
203208
final IRBlock postDominanceFrontier() {
204-
this.postDominates(result.getASuccessor()) and
205-
not this.strictlyPostDominates(result)
209+
this.getAPredecessor() = result and
210+
not this.immediatelyPostDominates(result)
211+
or
212+
exists(IRBlock prev | result = prev.postDominanceFrontier() |
213+
this.immediatelyPostDominates(prev) and
214+
not this.immediatelyPostDominates(result)
215+
)
206216
}
207217

208218
/**

csharp/ql/src/experimental/ir/implementation/raw/IRBlock.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ class IRBlock extends IRBlockBase {
161161
*/
162162
pragma[noinline]
163163
final IRBlock dominanceFrontier() {
164-
this.dominates(result.getAPredecessor()) and
165-
not this.strictlyDominates(result)
164+
this.getASuccessor() = result and
165+
not this.immediatelyDominates(result)
166+
or
167+
exists(IRBlock prev | result = prev.dominanceFrontier() |
168+
this.immediatelyDominates(prev) and
169+
not this.immediatelyDominates(result)
170+
)
166171
}
167172

168173
/**
@@ -201,8 +206,13 @@ class IRBlock extends IRBlockBase {
201206
*/
202207
pragma[noinline]
203208
final IRBlock postDominanceFrontier() {
204-
this.postDominates(result.getASuccessor()) and
205-
not this.strictlyPostDominates(result)
209+
this.getAPredecessor() = result and
210+
not this.immediatelyPostDominates(result)
211+
or
212+
exists(IRBlock prev | result = prev.postDominanceFrontier() |
213+
this.immediatelyPostDominates(prev) and
214+
not this.immediatelyPostDominates(result)
215+
)
206216
}
207217

208218
/**

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRBlock.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ class IRBlock extends IRBlockBase {
161161
*/
162162
pragma[noinline]
163163
final IRBlock dominanceFrontier() {
164-
this.dominates(result.getAPredecessor()) and
165-
not this.strictlyDominates(result)
164+
this.getASuccessor() = result and
165+
not this.immediatelyDominates(result)
166+
or
167+
exists(IRBlock prev | result = prev.dominanceFrontier() |
168+
this.immediatelyDominates(prev) and
169+
not this.immediatelyDominates(result)
170+
)
166171
}
167172

168173
/**
@@ -201,8 +206,13 @@ class IRBlock extends IRBlockBase {
201206
*/
202207
pragma[noinline]
203208
final IRBlock postDominanceFrontier() {
204-
this.postDominates(result.getASuccessor()) and
205-
not this.strictlyPostDominates(result)
209+
this.getAPredecessor() = result and
210+
not this.immediatelyPostDominates(result)
211+
or
212+
exists(IRBlock prev | result = prev.postDominanceFrontier() |
213+
this.immediatelyPostDominates(prev) and
214+
not this.immediatelyPostDominates(result)
215+
)
206216
}
207217

208218
/**

0 commit comments

Comments
 (0)