Python ESSA: Fix performance of PythonSsaSourceVariable.hasRefinementEdge()

This commit is contained in:
Mark Shannon
2018-12-01 16:36:49 +00:00
parent d933152a54
commit f11b5ab42f

View File

@@ -79,24 +79,12 @@ abstract class PythonSsaSourceVariable extends SsaSourceVariable {
}
override predicate hasRefinementEdge(ControlFlowNode use, BasicBlock pred, BasicBlock succ) {
test_contains(pred.getLastNode(), use) and
use.(NameNode).uses(this) and
exists(ControlFlowNode test |
test.getAChild*() = use and
test.isBranch() and
test = pred.getLastNode()
) and
(pred.getAFalseSuccessor() = succ or pred.getATrueSuccessor() = succ)
and
(pred.getAFalseSuccessor() = succ or pred.getATrueSuccessor() = succ) and
/* There is a store to this variable -- We don't want to refine builtins */
exists(this.(Variable).getAStore()) and
/* There is at least one use or definition of the variable that is reachable by the test */
exists(ControlFlowNode n |
n = this.getAUse() or
this.hasDefiningNode(n) |
pred.(ConditionBlock).strictlyReaches(n.getBasicBlock())
)
exists(this.(Variable).getAStore())
}
override ControlFlowNode getASourceUse() {
result.(NameNode).uses(this)
or