Skip to content

Commit 74472d7

Browse files
committed
QLDocs: Document inline_late pragma
1 parent d55e9d5 commit 74472d7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

docs/codeql/ql-language-reference/annotations.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,38 @@ into the places where it is called. This can be useful when a predicate body is
289289
compute entirely, as it ensures that the predicate is evaluated with the other contextual information
290290
at the places where it is called.
291291

292+
``pragma[inline_late]``
293+
-----------------------
294+
295+
**Available for**: |non-member predicates|
296+
297+
The ``pragma[inline_late]`` annotation must be used in conjunction with a
298+
``bindingset[...]`` pragma and together they tell the QL optimiser to inline
299+
the annotated predicate after join ordering and to join order callers and callee
300+
based on the given binding set. This can be useful to prevent the optimiser
301+
from choosing a sub-optimal join order.
302+
303+
For instance, in the example below, the ``pragma[inline_late]`` and
304+
``bindingset[x]`` annotation specifies that calls to ``p`` should be join ordered
305+
in a context where ``x`` is already bound. This forces the join orderer to
306+
order the ``q(x)`` call before ``p(x)``, which is more computationally efficient
307+
than ordering ``p(x)`` before ``q(x)``.
308+
309+
.. code-block:: ql
310+
311+
bindingset[x]
312+
pragma[inline_late]
313+
predicate p(int x) { x in [0..100000000] }
314+
315+
predicate q(int x) { x in [0..10000] }
316+
317+
from int x
318+
where p(x) and q(x)
319+
select x
320+
321+
..
322+
323+
292324
``pragma[noinline]``
293325
--------------------
294326

0 commit comments

Comments
 (0)