Skip to content

Commit 4744cec

Browse files
authored
Merge pull request #576 from jbj/bbEntryReachesLocally-perf
C++: Fix performance of bbEntryReachesLocally (1.19)
2 parents f85e30a + 62d478e commit 4744cec

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,18 @@ abstract class LocalScopeVariableReachability extends string {
9696

9797
private predicate bbEntryReachesLocally(BasicBlock bb, SemanticStackVariable v, ControlFlowNode node) {
9898
exists(int n |
99-
node = bb.getNode(n) and isSink(node, v) |
100-
not exists(int m | m < n | isBarrier(bb.getNode(m), v))
99+
node = bb.getNode(n) and
100+
isSink(node, v)
101+
|
102+
not exists(this.firstBarrierIndexIn(bb, v))
103+
or
104+
n <= this.firstBarrierIndexIn(bb, v)
101105
)
102106
}
107+
108+
private int firstBarrierIndexIn(BasicBlock bb, SemanticStackVariable v) {
109+
result = min(int m | isBarrier(bb.getNode(m), v))
110+
}
103111
}
104112

105113
/**

0 commit comments

Comments
 (0)