[llvm] [IR] Allow nofree metadata to inttoptr (PR #153149)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 06:36:00 PDT 2025


================
@@ -12617,6 +12625,12 @@ metadata name ``<deref_bytes_node>`` corresponding to a metadata node with one
 ``i64`` entry.
 See ``dereferenceable_or_null`` metadata.
 
+The optional ``!nofree`` metadata must reference a single metadata name
+``<empty_node>`` corresponding to a metadata node with no entries.
+The existence of the ``!nofree`` metadata on the instruction tells the optimizer
+that the memory pointed by the pointer will not be freed during the execution of
+the function.
----------------
nikic wrote:

> Is it ok to say: "The memory pointed by the pointer will not be freed through the lifetime of the pointer"?

Assuming "lifetime of the pointer" is the time between allocation and free, this would always be true :)

I'm having trouble coming up with a good definition for this. Possibly we can just say "will not be freed after this point"? I guess that's true enough from the perspective of the device code.

https://github.com/llvm/llvm-project/pull/153149


More information about the llvm-commits mailing list