[libcxx-commits] [PATCH] D80057: [libc++][NFCI] Optimization to std::~unique_ptr
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 21 09:09:08 PDT 2020
zoecarver added a comment.
@ldionne
> In your example, I don't see what __p is.
`__p` is `nullptr`. I still think this might be a good solution. Essentially exiting `reset` early if `__ptr` is null. It eliminates the store without adding any compares and it will set the pointer to null the exact same number of times (so we don't add any unsafe memory issues).
@jfb It looks like <https://godbolt.org/z/UeVN2j> (in clang, at least) as long as everything can be inlined it can get rid of the store but, if the unique_ptr escapes, it can't. I would be really surprised if this change made a meaningful impact on performance, though. I think you'd need to create a lot of null unique_ptrs.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80057/new/
https://reviews.llvm.org/D80057
More information about the libcxx-commits
mailing list