Skip to content

Commit c66a44f

Browse files
authored
Merge pull request github#12162 from kaspersv/kaspersv/inline-late-docs
QLDocs: Document inline_late pragma
2 parents e877b16 + 1120498 commit c66a44f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,39 @@ 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. Together, they tell the QL optimiser to use the
299+
specified binding set for assessing join orders both in the body of the
300+
annotated predicate and at call sites and to inline the body into call sites
301+
after join ordering. This can be useful to prevent the optimiser from choosing
302+
a sub-optimal join order.
303+
304+
For instance, in the example below, the ``pragma[inline_late]`` and
305+
``bindingset[x]`` annotations specifiy that calls to ``p`` should be join ordered
306+
in a context where ``x`` is already bound. This forces the join orderer to
307+
order ``q(x)`` before ``p(x)``, which is more computationally efficient
308+
than ordering ``p(x)`` before ``q(x)``.
309+
310+
.. code-block:: ql
311+
312+
bindingset[x]
313+
pragma[inline_late]
314+
predicate p(int x) { x in [0..100000000] }
315+
316+
predicate q(int x) { x in [0..10000] }
317+
318+
from int x
319+
where p(x) and q(x)
320+
select x
321+
322+
..
323+
324+
292325
``pragma[noinline]``
293326
--------------------
294327

0 commit comments

Comments
 (0)