-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Revise the doc for __builtin_allow_runtime_check #104886
[docs] Revise the doc for __builtin_allow_runtime_check #104886
Conversation
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-clang Author: Fangrui Song (MaskRay) ChangesFix list formatting, improve the wording, and fix the description when Full diff: https://github.com/llvm/llvm-project/pull/104886.diff 1 Files Affected:
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 114e742f3561b7..d9c2814505ea2f 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3540,7 +3540,7 @@ the debugging experience.
``__builtin_allow_runtime_check``
---------------------------------
-``__builtin_allow_runtime_check`` return true if the check at the current
+``__builtin_allow_runtime_check`` returns true if the check at the current
program location should be executed. It is expected to be used to implement
``assert`` like checks which can be safely removed by optimizer.
@@ -3560,30 +3560,29 @@ program location should be executed. It is expected to be used to implement
**Description**
-``__builtin_allow_runtime_check`` is lowered to ` ``llvm.allow.runtime.check``
+``__builtin_allow_runtime_check`` is lowered to the `llvm.allow.runtime.check
<https://llvm.org/docs/LangRef.html#llvm-allow-runtime-check-intrinsic>`_
-builtin.
-
-The ``__builtin_allow_runtime_check()`` is expected to be used with control
-flow conditions such as in ``if`` to guard expensive runtime checks. The
-specific rules for selecting permitted checks can differ and are controlled by
-the compiler options.
-
-Flags to control checks:
-* ``-mllvm -lower-allow-check-percentile-cutoff-hot=N`` where N is PGO hotness
-cutoff in range ``[0, 999999]`` to disallow checks in hot code.
-* ``-mllvm -lower-allow-check-random-rate=P`` where P is number in range
-``[0.0, 1.0]`` representation probability of keeping a check.
-* If both flags are specified, ``-lower-allow-check-random-rate`` takes
-precedence.
-* If none is specified, ``__builtin_allow_runtime_check`` is lowered as
-``true``, allowing all checks.
-
-Parameter ``kind`` is a string literal representing a user selected kind for
-guarded check. It's unused now. It will enable kind-specific lowering in future.
-E.g. a higher hotness cutoff can be used for more expensive kind of check.
-
-Query for this feature with ``__has_builtin(__builtin_allow_runtime_check)``.
+intrinsic.
+
+The ``__builtin_allow_runtime_check()`` can be used within constrol structures
+like ``if`` to guard expensive runtime checks. The specific rules for selecting
+permitted checks can differ and are controlled by the compiler options.
+
+Options to control checks:
+
+* ``-mllvm -lower-allow-check-percentile-cutoff-hot=N``: Disable checks in hot
+ code marked by the profile summary with a hotness cutoff in the range ``[0,
+ 999999]`` (a larger N disables more checks).
+* ``-mllvm -lower-allow-check-random-rate=P``: Keep a check with probability P,
+ a floating point number in the range ``[0.0, 1.0]``.
+* If both options are specified, a check is disabled if either condition is satisfied.
+* If neither is specified, all checks are allowed.
+
+Parameter ``kind``, currently unused, is a string literal specifying the check
+kind. Future compiler versions may use this to allow for more granular control,
+such as applying different hotness cutoffs to different check kinds.
+
+Use ``__has_builtin(__builtin_allow_runtime_check)`` to determine if this intrinsic is supported.
``__builtin_nondeterministic_value``
------------------------------------
|
clang/docs/LanguageExtensions.rst
Outdated
kind. Future compiler versions may use this to allow for more granular control, | ||
such as applying different hotness cutoffs to different check kinds. | ||
|
||
Use ``__has_builtin(__builtin_allow_runtime_check)`` to determine if this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query -> Use
is inconsistent with the rest of the doc.
Created using spr 1.3.5-bogner
Fix list formatting, improve the wording, and fix the description when
both options (note: prefer "option" to "flag" when arguments are
supported) are specified.