Skip to content

Commit a67d865

Browse files
committed
Warn about possible non-inlining across overlay frontier
1 parent 8b3b2f5 commit a67d865

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @name Inline predicates across overlay frontier
3+
* @description Local inline predicates that are not annotated with `overlay[caller]` are
4+
* not be inlined across the overlay frontier. This may negatively affect performance.
5+
* @kind problem
6+
* @problem.severity warning
7+
* @id ql/inline-overlay-caller
8+
* @tags performance
9+
* @precision high
10+
*/
11+
12+
import ql
13+
14+
predicate mayBeLocal(AstNode n) {
15+
n.getAnAnnotation() instanceof OverlayLocal
16+
or
17+
n.getAnAnnotation() instanceof OverlayLocalQ
18+
or
19+
/*
20+
* The tree-sitter-ql grammar doesn't support annotations on
21+
* file-level module declarations. To work around that, we
22+
* consider any node in a file that contains an overlay[local]
23+
* or overlay[local?] annotation to be potentially local.
24+
*/
25+
26+
exists(AstNode m |
27+
n.getLocation().getFile() = m.getLocation().getFile() and
28+
mayBeLocal(m)
29+
)
30+
}
31+
32+
from Predicate p
33+
where
34+
mayBeLocal(p) and
35+
p.getAnAnnotation() instanceof Inline and
36+
not p.getAnAnnotation() instanceof OverlayCaller and
37+
not p.isPrivate()
38+
select p,
39+
"This possibly local non-private inline predicate will not " +
40+
"be inlined across the overlay frontier. Consider adding an " +
41+
"`overlay[caller]` annotation to allow inlining across the " +
42+
"overlay frontier. Note that adding an `overlay[caller]` annotation " +
43+
"affects semantics under overlay evaluation."

0 commit comments

Comments
 (0)