Skip to content

Commit 434815b

Browse files
authored
Merge pull request #13764 from MathiasVP/fix-fp-in-missing-noinline
QL: Fix FP in `ql/missing-noinline`
2 parents 475a892 + 5fa70b0 commit 434815b

File tree

4 files changed

+81
-4
lines changed

4 files changed

+81
-4
lines changed

ql/ql/src/queries/performance/MissingNoinline.ql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ where
1818
not decl.getAnAnnotation() instanceof NoMagic and
1919
not decl.getAnAnnotation() instanceof NoOpt and
2020
not decl.getAnAnnotation().getName() = "cached" and
21-
// If it's marked as inline it's probably because the QLDoc says something like
22-
// "this predicate is inlined because it gives a better join-order".
23-
not decl.getAnAnnotation() instanceof Inline
24-
select decl, "This predicate might be inlined."
21+
// If it's marked as inline (or has at least one bindingset annotation)
22+
// it's probably because the QLDoc says something like "this predicate
23+
// is inlined because it gives a better join-order".
24+
not decl.getAnAnnotation() instanceof Inline and
25+
not decl.getAnAnnotation() instanceof BindingSet
26+
select decl, "This predicate should probably be marked pragma[noinline] to prevent inlining."
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| Test.qll:8:11:8:25 | ClasslessPredicate missingNoInline | This predicate should probably be marked pragma[noinline] to prevent inlining. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
queries/performance/MissingNoinline.ql
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import ql
2+
3+
/**
4+
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
5+
*
6+
* This predicate exists to fix a join order.
7+
*/
8+
predicate missingNoInline(AddExpr add, Expr e1, Expr e2) {
9+
// BAD
10+
add.getLeftOperand() = e1 and
11+
add.getRightOperand() = e2
12+
}
13+
14+
/**
15+
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
16+
*
17+
* This predicate exists to fix a join order.
18+
*/
19+
pragma[noinline]
20+
predicate noInlined(AddExpr add, Expr e1, Expr e2) {
21+
// GOOD
22+
add.getLeftOperand() = e1 and
23+
add.getRightOperand() = e2
24+
}
25+
26+
/**
27+
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
28+
*
29+
* This predicate exists to fix a join order.
30+
*/
31+
pragma[nomagic]
32+
predicate nomagicd(AddExpr add, Expr e1, Expr e2) {
33+
// GOOD
34+
add.getLeftOperand() = e1 and
35+
add.getRightOperand() = e2
36+
}
37+
38+
/**
39+
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
40+
*
41+
* This predicate exists to fix a join order.
42+
*/
43+
pragma[inline]
44+
predicate inlined(AddExpr add, Expr e1, Expr e2) {
45+
// GOOD
46+
add.getLeftOperand() = e1 and
47+
add.getRightOperand() = e2
48+
}
49+
50+
/**
51+
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
52+
*
53+
* This predicate exists to fix a join order.
54+
*/
55+
bindingset[add]
56+
predicate hasBindingset(AddExpr add, Expr e1, Expr e2) {
57+
// GOOD
58+
add.getLeftOperand() = e1 and
59+
add.getRightOperand() = e2
60+
}
61+
62+
/**
63+
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
64+
*
65+
* This predicate exists to fix a join order.
66+
*/
67+
pragma[noopt]
68+
predicate noOpted(AddExpr add, Expr e1, Expr e2) {
69+
// GOOD
70+
add instanceof AddExpr and
71+
add.getLeftOperand() = e1 and
72+
add.getRightOperand() = e2
73+
}

0 commit comments

Comments
 (0)