Skip to content

Commit 0ca3f60

Browse files
committed
Python: Fix bad join in PointsToContext.appliesTo
Two related fixes. First, I removed the pragmas from `appliesTo`, as these were actually causing a huge cartesian product to be created in `RangeIterationVariableFact.pointsTo` and `ReModulePointToExtension.pointsTo`. On `python/cpython`, at least, this caused a reduction of tuples from ~2.7 billion to ~2 billion. However this also caused `PointsToContext.fromCall/2` to get a worse join-order, so I inlined the definition and added a pragma _there_, and that fixed the issue.
1 parent cd62cda commit 0ca3f60

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

python/ql/lib/semmle/python/pointsto/PointsToContext.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class PointsToContext extends TPointsToContext {
149149

150150
/** Holds if `call` is the call-site from which this context was entered and `outer` is the caller's context. */
151151
predicate fromCall(CallNode call, PointsToContext caller) {
152-
caller.appliesTo(call) and
152+
caller.appliesToScope(pragma[only_bind_into](call.getScope())) and
153153
this = TCallContext(call, caller, _)
154154
}
155155

@@ -187,11 +187,7 @@ class PointsToContext extends TPointsToContext {
187187

188188
/** Holds if this context can apply to the CFG node `n`. */
189189
pragma[inline]
190-
predicate appliesTo(ControlFlowNode n) {
191-
exists(Scope s |
192-
this.appliesToScope(pragma[only_bind_into](s)) and pragma[only_bind_into](s) = n.getScope()
193-
)
194-
}
190+
predicate appliesTo(ControlFlowNode n) { this.appliesToScope(n.getScope()) }
195191

196192
/** Holds if this context is a call context. */
197193
predicate isCall() { this = TCallContext(_, _, _) }

0 commit comments

Comments
 (0)