[PATCH] D60074: [Attributor] Deduce "no-recurse" function attribute
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 5 18:23:11 PDT 2019
jdoerfert added a comment.
In D60074#1531809 <https://reviews.llvm.org/D60074#1531809>, @efriedma wrote:
> Is it actually correct to derive norecurse like this?
>
> Suppose I have two functions:
>
> void f(int x) { if (x) { g(); } }
> void g() { f(0); }
>
>
> As far as I can tell, it would be correct to mark g() norecurse. And if g() is marked norecurse, we'll mark f() norecurse, which is wrong.
We should/do not mark `g` as `norecurse` in this example. At least not if `f` is externally visible.
> Granted, this is being sort of pedantic with the definition in LangRef, which says the function "does not call itself". It might make sense to redefine norecurse to mean the function doesn't call "any function currently on the stack", instead of just itself.
What we did before and with this patch is derive `norecurse` only if no call to a recursive function is contained. So in contrast to other attributes we actually do not look at the optimistic/assumed state of called functions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60074/new/
https://reviews.llvm.org/D60074
More information about the llvm-commits
mailing list