SSA: Update input to use member predicates.

This commit is contained in:
Anders Schack-Mulligen
2025-08-18 14:03:49 +02:00
parent 119837bb1d
commit bb3abc815f
24 changed files with 147 additions and 206 deletions

View File

@@ -1082,9 +1082,15 @@ class BasicBlock extends @py_flow_node {
* Dominance frontier of a node x is the set of all nodes `other` such that `this` dominates a predecessor
* of `other` but does not strictly dominate `other`
*/
pragma[noinline]
predicate dominanceFrontier(BasicBlock other) {
this.dominates(other.getAPredecessor()) and not this.strictlyDominates(other)
predicate dominanceFrontier(BasicBlock other) { this.inDominanceFrontier(other) }
predicate inDominanceFrontier(BasicBlock df) {
this = df.getAPredecessor() and not this = df.getImmediateDominator()
or
exists(BasicBlock prev | prev.inDominanceFrontier(df) |
this = prev.getImmediateDominator() and
not this = df.getImmediateDominator()
)
}
private ControlFlowNode firstNode() { result = this }

View File

@@ -23,7 +23,9 @@ private module CaptureInput implements Shared::InputSig<Location> {
predicate isConstructor() { none() }
}
class BasicBlock extends PY::BasicBlock {
final private class PyBasicBlock = PY::BasicBlock;
class BasicBlock extends PyBasicBlock {
int length() { result = count(int i | exists(this.getNode(i))) }
Callable getEnclosingCallable() { result = this.getScope() }
@@ -34,14 +36,16 @@ private module CaptureInput implements Shared::InputSig<Location> {
// and we just need a way to identify the basic block
// during debugging, so this will be serviceable.
Location getLocation() { result = super.getNode(0).getLocation() }
BasicBlock getASuccessor() { result = super.getASuccessor() }
BasicBlock getImmediateDominator() { result = super.getImmediateDominator() }
predicate inDominanceFrontier(BasicBlock df) { super.inDominanceFrontier(df) }
}
class ControlFlowNode = PY::ControlFlowNode;
BasicBlock getImmediateBasicBlockDominator(BasicBlock bb) { result = bb.getImmediateDominator() }
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() }
class CapturedVariable extends LocalVariable {
Function f;