Skip to content
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

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented Aug 20, 2024

Fix list formatting, improve the wording, and fix the description when
both options (note: prefer "option" to "flag" when arguments are
supported) are specified.

Created using spr 1.3.5-bogner
@MaskRay MaskRay requested a review from vitalybuka August 20, 2024 00:30
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Aug 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 20, 2024

@llvm/pr-subscribers-clang

Author: Fangrui Song (MaskRay)

Changes

Fix list formatting, improve the wording, and fix the description when
both options (note: prefer "option" to "flag" when arguments are
supported) are specified.


Full diff: https://github.com/llvm/llvm-project/pull/104886.diff

1 Files Affected:

  • (modified) clang/docs/LanguageExtensions.rst (+23-24)
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``
 ------------------------------------

.
Created using spr 1.3.5-bogner
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
Copy link
Collaborator

@vitalybuka vitalybuka Aug 20, 2024

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
.
Created using spr 1.3.5-bogner
@MaskRay MaskRay merged commit b5f3e28 into main Aug 20, 2024
6 of 8 checks passed
@MaskRay MaskRay deleted the users/MaskRay/spr/docs-revise-the-doc-for-__builtin_allow_runtime_check branch August 20, 2024 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants