[llvm] [LangRef] Try to clarify mustprogress wording. (PR #90510)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 11:34:28 PDT 2024
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/90510
Ensure it's clear that:
- Infinite loops in non-mustprogress functions are well-defined, even if they're called by mustprogress functions.
- Infinite recursion in mustprogress functions is not well-defined.
Looking at D86233, it's clear this was the intent, but the "transitive" wording is ambiguous. Instead, just explicitly state that infinite loops written in non-mustprogress functions count as progress.
>From 95fdc397e93caca07274d6a80a8cc5628d537eef Mon Sep 17 00:00:00 2001
From: Eli Friedman <efriedma at quicinc.com>
Date: Mon, 29 Apr 2024 11:11:44 -0700
Subject: [PATCH] [LangRef] Try to clarify mustprogress wording.
Try to ensure it's clear that:
- Infinite loops in non-mustprogress functions are well-defined, even
if they're called by mustprogress functions.
- Infinite recursion in mustprogress functions is not well-defined.
Looking at D86233, it's clear this was the intent, but the "transitive"
wording is ambiguous. Instead, just explicitly state that infinite loops
written in non-mustprogress functions count as progress.
---
llvm/docs/LangRef.rst | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 37662f79145d67..7441d76470d288 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -2447,12 +2447,14 @@ example:
memory access, I/O, or other synchronization. The ``mustprogress``
attribute is intended to model the requirements of the first section of
[intro.progress] of the C++ Standard. As a consequence, a loop in a
- function with the `mustprogress` attribute can be assumed to terminate if
+ function with the ``mustprogress`` attribute can be assumed to terminate if
it does not interact with the environment in an observable way, and
- terminating loops without side-effects can be removed. If a `mustprogress`
- function does not satisfy this contract, the behavior is undefined. This
- attribute does not apply transitively to callees, but does apply to call
- sites within the function. Note that `willreturn` implies `mustprogress`.
+ terminating loops without side-effects can be removed. If a ``mustprogress``
+ function does not satisfy this contract, the behavior is undefined. If a
+ ``mustprogress`` function calls a function not marked ``mustprogress``,
+ and that function never returns, the program is well-defined even if there
+ isn't any other observable progress. Note that ``willreturn`` implies
+ ``mustprogress``.
``"warn-stack-size"="<threshold>"``
This attribute sets a threshold to emit diagnostics once the frame size is
known should the frame size exceed the specified value. It takes one
More information about the llvm-commits
mailing list