Skip to content

Commit 08b1431

Browse files
authored
Merge pull request #600 from markshannon/python-fix-performance-refinement-edge
Python ESSA: Fix performance of PythonSsaSourceVariable.hasRefinementEdge()
2 parents 8493518 + f11b5ab commit 08b1431

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

python/ql/src/semmle/python/dataflow/SsaDefinitions.qll

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,12 @@ abstract class PythonSsaSourceVariable extends SsaSourceVariable {
7979
}
8080

8181
override predicate hasRefinementEdge(ControlFlowNode use, BasicBlock pred, BasicBlock succ) {
82+
test_contains(pred.getLastNode(), use) and
8283
use.(NameNode).uses(this) and
83-
exists(ControlFlowNode test |
84-
test.getAChild*() = use and
85-
test.isBranch() and
86-
test = pred.getLastNode()
87-
) and
88-
(pred.getAFalseSuccessor() = succ or pred.getATrueSuccessor() = succ)
89-
and
84+
(pred.getAFalseSuccessor() = succ or pred.getATrueSuccessor() = succ) and
9085
/* There is a store to this variable -- We don't want to refine builtins */
91-
exists(this.(Variable).getAStore()) and
92-
/* There is at least one use or definition of the variable that is reachable by the test */
93-
exists(ControlFlowNode n |
94-
n = this.getAUse() or
95-
this.hasDefiningNode(n) |
96-
pred.(ConditionBlock).strictlyReaches(n.getBasicBlock())
97-
)
86+
exists(this.(Variable).getAStore())
9887
}
99-
10088
override ControlFlowNode getASourceUse() {
10189
result.(NameNode).uses(this)
10290
or

0 commit comments

Comments
 (0)