cache more basicblock predicates

This commit is contained in:
Erik Krogh Kristensen
2021-12-11 15:39:29 +01:00
parent 79713e0ef8
commit 040196f40d
2 changed files with 13 additions and 5 deletions

View File

@@ -1012,9 +1012,7 @@ class BasicBlock extends @py_flow_node {
}
/** Whether this basic block dominates the other */
cached
predicate dominates(BasicBlock other) {
Stages::AST::ref() and
this = other
or
this.strictlyDominates(other)
@@ -1060,7 +1058,11 @@ class BasicBlock extends @py_flow_node {
}
/** Gets a successor to this basic block */
BasicBlock getASuccessor() { result = this.getLastNode().getASuccessor().getBasicBlock() }
cached
BasicBlock getASuccessor() {
Stages::AST::ref() and
result = this.getLastNode().getASuccessor().getBasicBlock()
}
/** Gets a predecessor to this basic block */
BasicBlock getAPredecessor() { result.getASuccessor() = this }
@@ -1130,7 +1132,11 @@ class BasicBlock extends @py_flow_node {
}
/** Holds if this basic block strictly reaches the other. Is the start of other reachable from the end of this. */
predicate strictlyReaches(BasicBlock other) { this.getASuccessor+() = other }
cached
predicate strictlyReaches(BasicBlock other) {
Stages::AST::ref() and
this.getASuccessor+() = other
}
/** Holds if this basic block reaches the other. Is the start of other reachable from the end of this. */
predicate reaches(BasicBlock other) { this = other or this.strictlyReaches(other) }

View File

@@ -80,7 +80,9 @@ module Stages {
or
any(PyFlow::BasicBlock b).strictlyDominates(_)
or
any(PyFlow::BasicBlock b).dominates(_)
any(PyFlow::BasicBlock b).strictlyReaches(_)
or
exists(any(PyFlow::BasicBlock b).getASuccessor())
or
exists(any(PyFlow::ControlFlowNode b).getScope())
or