Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2e596f

Browse files
C++: Improve join order in IR reachability
1 parent 99d33f9 commit b2e596f

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/reachability/ReachableBlock.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ IRBlock getAFeasiblePredecessor(IRBlock successor) {
2222
}
2323

2424
predicate isBlockReachable(IRBlock block) {
25-
getAFeasiblePredecessor*(block) = block.getFunctionIR().getEntryBlock()
25+
exists(FunctionIR f |
26+
getAFeasiblePredecessor*(block) = f.getEntryBlock()
27+
)
2628
}
2729

2830
predicate isInstructionReachable(Instruction instr) {
@@ -43,7 +45,9 @@ class ReachableInstruction extends Instruction {
4345

4446
module Graph {
4547
predicate isEntryBlock(ReachableBlock block) {
46-
block = block.getFunctionIR().getEntryBlock()
48+
exists(FunctionIR f |
49+
block = f.getEntryBlock()
50+
)
4751
}
4852

4953
predicate blockSuccessor(ReachableBlock pred, ReachableBlock succ) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ IRBlock getAFeasiblePredecessor(IRBlock successor) {
2222
}
2323

2424
predicate isBlockReachable(IRBlock block) {
25-
getAFeasiblePredecessor*(block) = block.getFunctionIR().getEntryBlock()
25+
exists(FunctionIR f |
26+
getAFeasiblePredecessor*(block) = f.getEntryBlock()
27+
)
2628
}
2729

2830
predicate isInstructionReachable(Instruction instr) {
@@ -43,7 +45,9 @@ class ReachableInstruction extends Instruction {
4345

4446
module Graph {
4547
predicate isEntryBlock(ReachableBlock block) {
46-
block = block.getFunctionIR().getEntryBlock()
48+
exists(FunctionIR f |
49+
block = f.getEntryBlock()
50+
)
4751
}
4852

4953
predicate blockSuccessor(ReachableBlock pred, ReachableBlock succ) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ IRBlock getAFeasiblePredecessor(IRBlock successor) {
2222
}
2323

2424
predicate isBlockReachable(IRBlock block) {
25-
getAFeasiblePredecessor*(block) = block.getFunctionIR().getEntryBlock()
25+
exists(FunctionIR f |
26+
getAFeasiblePredecessor*(block) = f.getEntryBlock()
27+
)
2628
}
2729

2830
predicate isInstructionReachable(Instruction instr) {
@@ -43,7 +45,9 @@ class ReachableInstruction extends Instruction {
4345

4446
module Graph {
4547
predicate isEntryBlock(ReachableBlock block) {
46-
block = block.getFunctionIR().getEntryBlock()
48+
exists(FunctionIR f |
49+
block = f.getEntryBlock()
50+
)
4751
}
4852

4953
predicate blockSuccessor(ReachableBlock pred, ReachableBlock succ) {

0 commit comments

Comments
 (0)