[PATCH] D66439: [LibFunc] "free" captures the pointer operand

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 15:42:57 PDT 2019


jdoerfert added a comment.

In D66439#1638284 <https://reviews.llvm.org/D66439#1638284>, @efriedma wrote:

> Is there some practical issue I'm missing?


I should have added my motivation:

I want heap2stack transformation under different circumstances, one of which is:

- whenever all capturing uses of a malloc are in free calls, we can perform the heap2stack transformation (because no one else can know about the pointer).

Now this is a different approach then the one originally proposed by @hfinkel, which was more along the lines of:

- whenever all paths lead *must* lead a free of the pointer (so no unwinding, etc.) we can perform heap2stack

They should catch different cases but the first is easier (IMHO).

The problem now is that non-capturing uses can free the pointer as well.

>> there is no reason "free" could not put the pointer value in a "free-table"
> 
> Data structures which are internal to the malloc implementation are considered opaque; otherwise, we couldn't add any attribute markings to malloc.

Fair point. Though I'm unsure why we need the nocapture here anyway. I guess if it otherwise confuses the alias analysis somehow (which I'm not really sure of in reality) we should consider lifetime markers instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66439





More information about the llvm-commits mailing list