[PATCH] D47747: [LangRef] Clarify "undefined" for various instructions.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 6 13:14:43 PDT 2018
efriedma added inline comments.
================
Comment at: docs/LangRef.rst:1131
+ the duration of the function. If the pointer cannot be dereferenced at any
+ point in the function, the behavior is undefined. This
attribute may only be applied to pointer typed parameters. A pointer that
----------------
hfinkel wrote:
> Chatting offline with @chandlerc and @rsmith , we currently have a problem with the way we use dereferenceable in Clang. We add this attribute for references, but it's possible to free the underlying storage during the execution of the function. I'd prefer to fix this by saying that dereferenceable only guarantees its properties at function entry, as this lets us preserve some of the optimization benefit (where the existing semantics can be obtained, in large part, by combining dereferenceable with noalias or noalias metadata).
>
> We should discuss what we'd like to do here.
"Duration of the function" reflects what's actually implemented at the moment. And it's generally useful even if we can't use it for C++ references. C structs which are passed/returned indirectly work this way; Rust references also work like this.
If "dereferencable on entry to the function" would be useful for C++, I think it should be a separate attribute.
Since this is apparently controversial, I'll split "dereferencable" it into it's own patch, so we can continue discussing it.
Repository:
rL LLVM
https://reviews.llvm.org/D47747
More information about the llvm-commits
mailing list