QL: Fix FP in 'ql/missing-noinline'.

This commit is contained in:
Mathias Vorreiter Pedersen
2023-07-18 17:37:07 +01:00
parent d41d2bc29e
commit 3b3f374223
3 changed files with 79 additions and 3 deletions

View File

@@ -18,7 +18,9 @@ where
not decl.getAnAnnotation() instanceof NoMagic and
not decl.getAnAnnotation() instanceof NoOpt and
not decl.getAnAnnotation().getName() = "cached" and
// If it's marked as inline it's probably because the QLDoc says something like
// "this predicate is inlined because it gives a better join-order".
not decl.getAnAnnotation() instanceof Inline
// If it's marked as inline (or has at least one bindingset annotation)
// it's probably because the QLDoc says something like "this predicate
// is inlined because it gives a better join-order".
not decl.getAnAnnotation() instanceof Inline and
not decl.getAnAnnotation() instanceof BindingSet
select decl, "This predicate might be inlined."

View File

@@ -0,0 +1 @@
queries/performance/MissingNoinline.ql

View File

@@ -0,0 +1,73 @@
import ql
/**
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
*
* This predicate exists to fix a join order.
*/
predicate missingNoInline(AddExpr add, Expr e1, Expr e2) {
// BAD
add.getLeftOperand() = e1 and
add.getRightOperand() = e2
}
/**
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
*
* This predicate exists to fix a join order.
*/
pragma[noinline]
predicate noInlined(AddExpr add, Expr e1, Expr e2) {
// GOOD
add.getLeftOperand() = e1 and
add.getRightOperand() = e2
}
/**
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
*
* This predicate exists to fix a join order.
*/
pragma[nomagic]
predicate nomagicd(AddExpr add, Expr e1, Expr e2) {
// GOOD
add.getLeftOperand() = e1 and
add.getRightOperand() = e2
}
/**
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
*
* This predicate exists to fix a join order.
*/
pragma[inline]
predicate inlined(AddExpr add, Expr e1, Expr e2) {
// GOOD
add.getLeftOperand() = e1 and
add.getRightOperand() = e2
}
/**
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
*
* This predicate exists to fix a join order.
*/
bindingset[add]
predicate hasBindingset(AddExpr add, Expr e1, Expr e2) {
// GOOD
add.getLeftOperand() = e1 and
add.getRightOperand() = e2
}
/**
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
*
* This predicate exists to fix a join order.
*/
pragma[noopt]
predicate noOpted(AddExpr add, Expr e1, Expr e2) {
// GOOD
add instanceof AddExpr and
add.getLeftOperand() = e1 and
add.getRightOperand() = e2
}