[PATCH] D61652: [Attr] Introduce dereferenceable_globally

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 09:06:34 PST 2019


jdoerfert marked 2 inline comments as done.
jdoerfert added inline comments.


================
Comment at: llvm/docs/LangRef.rst:1170
+    ``dereferenceable(<n>)`` property *at any program point*, starting from the
+    definition of the value to the termination of the program. Thus, unlike
+    pointer values annotated with ``dereferenceable(<n>)``,
----------------
RalfJung wrote:
> In Rust, we are using the existing  `dereferenceable` attribute on function parameters, and we are generally happy with its semantics, which we interpreted to be "this pointer is dereferenceable for the entire duration of this function call". We automatically set this attribute for all references passed to a function, which in Rust (unlike in C++) are guaranteed to not be deallocated while the function is ongoing.
> 
> However, the new `dereferenceable_globally` that is being proposed here is useless for us: even memory pointed to by references *does* eventually get deallocated. We hence cannot set that attribute. So, the patch as proposed constitutes a big regression in terms of the kind of information that the Rust frontend can provide to LLVM.
My first thought: `dereferenceable` + `nofree` on the argument should give you the semantics you think ` dereferenceable` has now.

I will ping you once I rebase the updated users of ` dereferenceable` which will then look at the new ones (`nofree`, ` dereferenceable_globally`, ..) as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61652/new/

https://reviews.llvm.org/D61652





More information about the llvm-commits mailing list