[llvm] [FuncAttrs] Relax norecurse attribute inference (PR #139943)
Usha Gupta via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 03:55:56 PDT 2025
================
@@ -2071,24 +2072,36 @@ static void addNoRecurseAttrs(const SCCNodeSet &SCCNodes,
if (!F || !F->hasExactDefinition() || F->doesNotRecurse())
return;
- // If all of the calls in F are identifiable and are to norecurse functions, F
- // is norecurse. This check also detects self-recursion as F is not currently
- // marked norecurse, so any called from F to F will not be marked norecurse.
- for (auto &BB : *F)
- for (auto &I : BB.instructionsWithoutDebug())
+ if (F->hasAddressTaken())
----------------
usha1830 wrote:
Thanks for the review @david-arm.
> ```
> foo() -> bar() -> moo() -> foo()
> ```
>
> or
>
> ```
> boo() -> foo() -> bar() -> moo() -> boo()
> ```
These cases should be covered with an earlier check in the function as the SCC for foo will have more than 1 node
` if (SCCNodes.size() != 1) return;`
I have added a test in this PR for multi-SCC cases like this.
https://github.com/llvm/llvm-project/pull/139943
More information about the llvm-commits
mailing list