[all-commits] [llvm/llvm-project] 191aa2: [LangRef] Do not allow free via synchronization in...
Nikita Popov via All-commits
all-commits at lists.llvm.org
Wed May 27 23:56:45 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 191aa295d9c9fe83411ae5cdfeb8a6bb8decb3d2
https://github.com/llvm/llvm-project/commit/191aa295d9c9fe83411ae5cdfeb8a6bb8decb3d2
Author: Nikita Popov <npopov at redhat.com>
Date: 2026-05-28 (Thu, 28 May 2026)
Changed paths:
M llvm/docs/LangRef.rst
Log Message:
-----------
[LangRef] Do not allow free via synchronization in nofree (#195658)
The nofree attribute is currently specified to only forbid direct free
calls inside the function. A nofree function is still allowed to compel
a pointer to be freed by a different thread through synchronization.
This is currently only spelled out for the function-level nofree
attribute, but I assume the same semantics also hold for argument nofree
(and this matches how the Attributor implementation infers it).
The original motivation for this definition was to keep the attributes
orthogonal and independently inferable. However, the problem is that
nosync is a too strong condition: It excludes *any* synchronization, not
just synchronization that results in the free of a pointer.
Some frontends like Rust can guarantee that most pointer arguments
cannot be freed for the duration of a function call, including via
synchronization. However, they cannot guarantee that no synchronization
takes place at all. The current definition of nofree makes this
inexpressible in LLVM IR, which blocks further progress on
dereferenceable-at-point semantics.
This PR makes two changes to the nofree spec:
* Function-level nofree now disallows free via synchronization,
specified in terms of happens-before.
* Argument-level nofree is now specified in terms of provenance: The
argument has derived provenance that makes it UB to free during the
execution of the function (which includes freeing on another thread with
appropriate synchronization). This also clarified that argument-level
nofree only applies to the particular pointer (similar to `captures`
etc). The underlying object may still be freed via a different argument
to which the same pointer is passed.
Note: The necessary inference changes for the new semantics will
be implemented in a separate PR.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list