[llvm] [LangRef] Do not allow free via synchronization in nofree (PR #195658)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 09:24:43 PDT 2026
nikic wrote:
> Which makes me realize why, among other things, the old spec was not addressing / engaging with synchronization at all. Just wondering, could it make sense to mirror the function-level happens-before formulation for the argument attribute as well, e.g., a free through a pointer based on this argument on another thread violates argument `nofree` only if it happens-before the function exit and does not happens-before the function entry, or might it be too contrived? I think the temporal / informal form (until function returns) is still fine though.
Done, though I omitted the part about happens-before the function entry, as the pointer/provenance is only created on function entry.
TBH I'm not entirely happy with this definition of "well-defined if not (free happens-before return)". I think for the provenance-based argument attribute, a more natural definition would have been "well-defined if return happens-before free", because this allows us to determine whether UB occurs at the point of the free. But this definition would be incompatible with the function-level nofree, which is also undesirable, because it prevents cross-inference.
https://github.com/llvm/llvm-project/pull/195658
More information about the llvm-commits
mailing list