Skip to content

Commit b5f3e28

Browse files
authored
[docs] Revise the doc for __builtin_allow_runtime_check
Fix list formatting, improve the wording, and fix the description when both options (note: prefer "option" to "flag" when arguments are supported) are specified. Pull Request: #104886
1 parent baa6627 commit b5f3e28

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,7 @@ the debugging experience.
35403540
``__builtin_allow_runtime_check``
35413541
---------------------------------
35423542
3543-
``__builtin_allow_runtime_check`` return true if the check at the current
3543+
``__builtin_allow_runtime_check`` returns true if the check at the current
35443544
program location should be executed. It is expected to be used to implement
35453545
``assert`` like checks which can be safely removed by optimizer.
35463546
@@ -3560,28 +3560,25 @@ program location should be executed. It is expected to be used to implement
35603560
35613561
**Description**
35623562
3563-
``__builtin_allow_runtime_check`` is lowered to ` ``llvm.allow.runtime.check``
3563+
``__builtin_allow_runtime_check`` is lowered to the `llvm.allow.runtime.check
35643564
<https://llvm.org/docs/LangRef.html#llvm-allow-runtime-check-intrinsic>`_
3565-
builtin.
3566-
3567-
The ``__builtin_allow_runtime_check()`` is expected to be used with control
3568-
flow conditions such as in ``if`` to guard expensive runtime checks. The
3569-
specific rules for selecting permitted checks can differ and are controlled by
3570-
the compiler options.
3571-
3572-
Flags to control checks:
3573-
* ``-mllvm -lower-allow-check-percentile-cutoff-hot=N`` where N is PGO hotness
3574-
cutoff in range ``[0, 999999]`` to disallow checks in hot code.
3575-
* ``-mllvm -lower-allow-check-random-rate=P`` where P is number in range
3576-
``[0.0, 1.0]`` representation probability of keeping a check.
3577-
* If both flags are specified, ``-lower-allow-check-random-rate`` takes
3578-
precedence.
3579-
* If none is specified, ``__builtin_allow_runtime_check`` is lowered as
3580-
``true``, allowing all checks.
3581-
3582-
Parameter ``kind`` is a string literal representing a user selected kind for
3583-
guarded check. It's unused now. It will enable kind-specific lowering in future.
3584-
E.g. a higher hotness cutoff can be used for more expensive kind of check.
3565+
intrinsic.
3566+
3567+
The ``__builtin_allow_runtime_check()`` can be used within constrol structures
3568+
like ``if`` to guard expensive runtime checks. The return value is determined
3569+
by the following compiler options and may differ per call site:
3570+
3571+
* ``-mllvm -lower-allow-check-percentile-cutoff-hot=N``: Disable checks in hot
3572+
code marked by the profile summary with a hotness cutoff in the range
3573+
``[0, 999999]`` (a larger N disables more checks).
3574+
* ``-mllvm -lower-allow-check-random-rate=P``: Keep a check with probability P,
3575+
a floating point number in the range ``[0.0, 1.0]``.
3576+
* If both options are specified, a check is disabled if either condition is satisfied.
3577+
* If neither is specified, all checks are allowed.
3578+
3579+
Parameter ``kind``, currently unused, is a string literal specifying the check
3580+
kind. Future compiler versions may use this to allow for more granular control,
3581+
such as applying different hotness cutoffs to different check kinds.
35853582
35863583
Query for this feature with ``__has_builtin(__builtin_allow_runtime_check)``.
35873584

0 commit comments

Comments
 (0)