[PATCH] D48239: [LangRef] Clarify meaning of "dereferencable" attribute/metadata.

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 9 19:04:49 PDT 2018


hfinkel added a comment.

In https://reviews.llvm.org/D48239#1156781, @efriedma wrote:

> PointerMayBeCaptured doesn't do the right thing.  The primary issue is that it only walks the uses of the argument; other pointers could alias the argument if it isn't also noalias.  (The other issue is that freeing a pointer doesn't count as capturing it.)


Ah, indeed. You're certainly correct. And free is marked as nocapture (which we'd likely prefer to keep, although free almost certainly does capture the pointer value in some physical sense, it does not do so in a way that will be visible to the rest of the program (except that it might be returned by some later malloc call)).

We'd need to model this directly for it to be useful (as an attribute that means that the function doesn't call free, or doesn't free a particular argument, or similar). I'll send an RFC about that.

> So instead, we have to scan every instruction in the function between the beginning of the function and the insertion point, which is going to be very expensive.  (Or if we set a tight limit on the number of instructions it will walk, it probably give up before it reaches the function's entry point.)


Repository:
  rL LLVM

https://reviews.llvm.org/D48239





More information about the llvm-commits mailing list