Further join order optimisations

This commit is contained in:
Chris Smowton 2024-10-03 22:17:44 +01:00
Родитель bf5ba33c2e
Коммит ed9a6bd820
6 изменённых файлов: 15 добавлений и 11 удалений

Просмотреть файл

@ -2137,6 +2137,7 @@ private predicate isTypeExprBottomUp(Expr e) {
* it may be the latter and so this predicate does not consider the expression to be
* a type expression.
*/
pragma[nomagic]
private predicate isTypeExprTopDown(Expr e) {
e = any(CompositeLit cl).getTypeExpr()
or

Просмотреть файл

@ -1481,7 +1481,7 @@ module IR {
override predicate refersTo(ValueEntity e) {
this instanceof MkLhs and
loc = e.getAReference()
pragma[only_bind_out](loc) = e.getAReference()
or
exists(WriteResultInstruction wr | this = MkResultWriteTarget(wr) |
e = wr.getResultVariable()

Просмотреть файл

@ -8,9 +8,9 @@ private import DataFlowPrivate
private predicate isInterfaceCallReceiver(
DataFlow::CallNode call, DataFlow::Node recv, InterfaceType tp, string m
) {
call.getReceiver() = recv and
pragma[only_bind_out](call).getReceiver() = recv and
recv.getType().getUnderlyingType() = tp and
m = call.getACalleeIncludingExternals().asFunction().getName()
m = pragma[only_bind_out](call).getACalleeIncludingExternals().asFunction().getName()
}
/** Gets a data-flow node that may flow into the receiver value of `call`, which is an interface value. */

Просмотреть файл

@ -525,6 +525,7 @@ module Public {
* As `getACalleeIncludingExternals`, except excluding external functions (those for which
* we lack a definition, such as standard library functions).
*/
pragma[nomagic]
FuncDef getACallee() { result = this.getACalleeIncludingExternals().getFuncDef() }
/**

Просмотреть файл

@ -284,9 +284,11 @@ signature predicate guardChecksSig(Node g, Expr e, boolean branch);
module BarrierGuard<guardChecksSig/3 guardChecks> {
/** Gets a node that is safely guarded by the given guard check. */
Node getABarrierNode() {
exists(ControlFlow::ConditionGuardNode guard, SsaWithFields var | result = var.getAUse() |
exists(ControlFlow::ConditionGuardNode guard, SsaWithFields var |
result = pragma[only_bind_out](var).getAUse()
|
guards(_, guard, _, var) and
guard.dominates(result.getBasicBlock())
pragma[only_bind_out](guard).dominates(result.getBasicBlock())
)
}
@ -353,7 +355,7 @@ module BarrierGuard<guardChecksSig/3 guardChecks> {
) {
exists(FuncDecl fd, Node arg, Node ret |
fd.getFunction() = f and
localFlow(inp.getExitNode(fd), arg) and
localFlow(inp.getExitNode(fd), pragma[only_bind_out](arg)) and
ret = outp.getEntryNode(fd) and
(
// Case: a function like "if someBarrierGuard(arg) { return true } else { return false }"

Просмотреть файл

@ -203,8 +203,8 @@ abstract class FunctionModel extends Function {
predicate taintStepForCall(DataFlow::Node pred, DataFlow::Node succ, DataFlow::CallNode c) {
c = this.getACall() and
exists(FunctionInput inp, FunctionOutput outp | this.hasTaintFlow(inp, outp) |
pred = inp.getNode(c) and
succ = outp.getNode(c)
pred = pragma[only_bind_out](inp).getNode(c) and
succ = pragma[only_bind_out](outp).getNode(c)
)
}
@ -383,9 +383,9 @@ predicate inputIsConstantIfOutputHasProperty(
) {
exists(Function f, FunctionInput inp, FunctionOutput outp, DataFlow::CallNode call |
functionEnsuresInputIsConstant(f, inp, outp, p) and
call = f.getACall() and
inputNode = inp.getNode(call) and
DataFlow::localFlow(outp.getNode(call), outputNode)
call = pragma[only_bind_out](f).getACall() and
inputNode = pragma[only_bind_out](inp).getNode(call) and
DataFlow::localFlow(pragma[only_bind_out](outp).getNode(call), outputNode)
)
}