Skip to content

Commit ed9a6bd

Browse files
committed
Further join order optimisations
1 parent bf5ba33 commit ed9a6bd

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

go/ql/lib/semmle/go/Expr.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,6 +2137,7 @@ private predicate isTypeExprBottomUp(Expr e) {
21372137
* it may be the latter and so this predicate does not consider the expression to be
21382138
* a type expression.
21392139
*/
2140+
pragma[nomagic]
21402141
private predicate isTypeExprTopDown(Expr e) {
21412142
e = any(CompositeLit cl).getTypeExpr()
21422143
or

go/ql/lib/semmle/go/controlflow/IR.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ module IR {
14811481

14821482
override predicate refersTo(ValueEntity e) {
14831483
this instanceof MkLhs and
1484-
loc = e.getAReference()
1484+
pragma[only_bind_out](loc) = e.getAReference()
14851485
or
14861486
exists(WriteResultInstruction wr | this = MkResultWriteTarget(wr) |
14871487
e = wr.getResultVariable()

go/ql/lib/semmle/go/dataflow/internal/DataFlowDispatch.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ private import DataFlowPrivate
88
private predicate isInterfaceCallReceiver(
99
DataFlow::CallNode call, DataFlow::Node recv, InterfaceType tp, string m
1010
) {
11-
call.getReceiver() = recv and
11+
pragma[only_bind_out](call).getReceiver() = recv and
1212
recv.getType().getUnderlyingType() = tp and
13-
m = call.getACalleeIncludingExternals().asFunction().getName()
13+
m = pragma[only_bind_out](call).getACalleeIncludingExternals().asFunction().getName()
1414
}
1515

1616
/** Gets a data-flow node that may flow into the receiver value of `call`, which is an interface value. */

go/ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ module Public {
525525
* As `getACalleeIncludingExternals`, except excluding external functions (those for which
526526
* we lack a definition, such as standard library functions).
527527
*/
528+
pragma[nomagic]
528529
FuncDef getACallee() { result = this.getACalleeIncludingExternals().getFuncDef() }
529530

530531
/**

go/ql/lib/semmle/go/dataflow/internal/DataFlowUtil.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,11 @@ signature predicate guardChecksSig(Node g, Expr e, boolean branch);
284284
module BarrierGuard<guardChecksSig/3 guardChecks> {
285285
/** Gets a node that is safely guarded by the given guard check. */
286286
Node getABarrierNode() {
287-
exists(ControlFlow::ConditionGuardNode guard, SsaWithFields var | result = var.getAUse() |
287+
exists(ControlFlow::ConditionGuardNode guard, SsaWithFields var |
288+
result = pragma[only_bind_out](var).getAUse()
289+
|
288290
guards(_, guard, _, var) and
289-
guard.dominates(result.getBasicBlock())
291+
pragma[only_bind_out](guard).dominates(result.getBasicBlock())
290292
)
291293
}
292294

@@ -353,7 +355,7 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
353355
) {
354356
exists(FuncDecl fd, Node arg, Node ret |
355357
fd.getFunction() = f and
356-
localFlow(inp.getExitNode(fd), arg) and
358+
localFlow(inp.getExitNode(fd), pragma[only_bind_out](arg)) and
357359
ret = outp.getEntryNode(fd) and
358360
(
359361
// Case: a function like "if someBarrierGuard(arg) { return true } else { return false }"

go/ql/lib/semmle/go/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ abstract class FunctionModel extends Function {
203203
predicate taintStepForCall(DataFlow::Node pred, DataFlow::Node succ, DataFlow::CallNode c) {
204204
c = this.getACall() and
205205
exists(FunctionInput inp, FunctionOutput outp | this.hasTaintFlow(inp, outp) |
206-
pred = inp.getNode(c) and
207-
succ = outp.getNode(c)
206+
pred = pragma[only_bind_out](inp).getNode(c) and
207+
succ = pragma[only_bind_out](outp).getNode(c)
208208
)
209209
}
210210

@@ -383,9 +383,9 @@ predicate inputIsConstantIfOutputHasProperty(
383383
) {
384384
exists(Function f, FunctionInput inp, FunctionOutput outp, DataFlow::CallNode call |
385385
functionEnsuresInputIsConstant(f, inp, outp, p) and
386-
call = f.getACall() and
387-
inputNode = inp.getNode(call) and
388-
DataFlow::localFlow(outp.getNode(call), outputNode)
386+
call = pragma[only_bind_out](f).getACall() and
387+
inputNode = pragma[only_bind_out](inp).getNode(call) and
388+
DataFlow::localFlow(pragma[only_bind_out](outp).getNode(call), outputNode)
389389
)
390390
}
391391

0 commit comments

Comments
 (0)