[llvm] [AA] No synchronization effects for never-escaping identified local (PR #193939)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 00:23:57 PDT 2026
nikic wrote:
> Is it legal to mark an argument to a parallel algorithm "captures(none)" if the function has appropriate synchronization and doesn't escape the pointer? I guess that's okay?
I think if you go by current LangRef wording, the answer to this is "no" (point 2 of the pointer capture section). But I think the answer *should* be "yes". I believe we should be defining (the provenance part of) `captures(none)` as returning a pointer with derived provenance, which drops all permissions when the function returns. In other words, I believe the statement that `captures(none)` should be making is "accesses via this pointer after the function returns are UB". This makes the definition independent of what you actually do with it during the function call. From that perspective, marking an argument to a parallel algorithm `captures(none)` should be fine, as long as the pointer doesn't continue to be used after the function returns. The fact that it (temporarily) escapes to another thread becomes irrelevant.
Though even that more liberal definition should be fine for the purpose of this change. After all, the "escaped" pointer can't be used anymore without UB.
https://github.com/llvm/llvm-project/pull/193939
More information about the llvm-commits
mailing list