Skip to content

Commit d8e1c20

Browse files
authored
[LangRef] Clarify norecurse attribute definition when a function could occur in a cycle in dynamic call-graph (llvm#157087)
Update the definition of the `norecurse` attribute to forbid marking a function as `norecurse` if any call path from its body may reach it (possibly through an external function without a visible definition). This makes it clear that `norecurse` excludes both direct and mutual recursion, even when recursion could arise through callees in separate modules. This kind of scenario only arises when norecurse is forced through a llvm user option `-mllvm -force-attribute=<fname>:norecurse` There are a few examples in llvm#157081 which shows that the function attribute inference incorrectly infers norecurse when the behavior (as per new definition) is not enforced.
1 parent aac8eb8 commit d8e1c20

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

llvm/docs/LangRef.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,9 +2256,16 @@ For example:
22562256
behavior at runtime if the function ever does dynamically return. Annotated
22572257
functions may still raise an exception, i.a., ``nounwind`` is not implied.
22582258
``norecurse``
2259-
This function attribute indicates that the function does not call itself
2260-
either directly or indirectly down any possible call path. This produces
2261-
undefined behavior at runtime if the function ever does recurse.
2259+
This function attribute indicates that the function is not recursive and
2260+
does not participate in recursion. This means that the function never
2261+
occurs inside a cycle in the dynamic call graph.
2262+
For example:
2263+
2264+
.. code-block:: llvm
2265+
2266+
fn -> other_fn -> fn ; fn is not norecurse
2267+
other_fn -> fn -> other_fn ; fn is not norecurse
2268+
fn -> other_fn -> other_fn ; fn is norecurse
22622269

22632270
.. _langref_willreturn:
22642271

0 commit comments

Comments
 (0)