[PATCH] D30178: Do not leak OpenedHandles

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 20 19:01:56 PST 2017


vsk added a comment.

In https://reviews.llvm.org/D30178#681888, @marsupial wrote:

> I get what ManagedStatic is supposed to be doing, but versus using a std::unique_ptr the cost seems more with it (both in terms of size and startup time).


I'm not so sure. First, the unique_ptr isn't very helpful, because it's destructor can't be called until the program terminates, at which point it just creates needless allocator traffic. Clang has `-disable-free` to work around this problem. This is why ManagedStatic allows compile servers to work: because `llvm_shutdown()` actually frees the memory held by ManagedStatics. Second, it looks like ManagedStatic has a trivial constructor, making it cheap in the case where you don't use this API.

> But I guess that conversation would add a bit of noise and doesn't have much to do with this patch.

I suppose so, its use here won't be changed.


Repository:
  rL LLVM

https://reviews.llvm.org/D30178





More information about the llvm-commits mailing list