[libcxx-commits] [PATCH] D81288: [Opt] Smart pointer lifetime optimizations pass.
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 5 11:45:25 PDT 2020
zoecarver created this revision.
zoecarver added reviewers: jfb, ldionne, EricWF.
Herald added subscribers: llvm-commits, libcxx-commits, dexonsmith, hiraditya, mgorny.
Herald added projects: libc++, LLVM.
Herald added a reviewer: libc++.
zoecarver marked an inline comment as done.
zoecarver added inline comments.
================
Comment at: libcxx/include/memory:2412
_LIBCPP_INLINE_VISIBILITY
+ __attribute__((abi_tag("__SEMANTICS_unique_ptr_move_const")))
unique_ptr(unique_ptr&& __u) _NOEXCEPT
----------------
Obviously these won't be part of the final patch. This is just an easy way to figure out which methods are important (both for me and the pass).
In Swift, there's a `@_semantics` decorator that can be applied to functions so the compiler can apply specific optimizations. Is there anything like that in clang? If not, would something like that be welcome and/or possible? If so, I'm happy to implement it.
This pass does one thing: constant fold away the destructor of `unique_ptr` based on ownership information we get form move semantics.
However, it is also (hopefully) the scaffolding for many more lifetime optimizations both around `unique_ptr` and other smart pointers.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81288
Files:
libcxx/include/memory
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/LinkAllPasses.h
llvm/include/llvm/Transforms/Scalar.h
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/lib/Transforms/Scalar/CMakeLists.txt
llvm/lib/Transforms/Scalar/Scalar.cpp
llvm/lib/Transforms/Scalar/SmartPtrLifetime.cpp
llvm/test/Transforms/SmartPtrLifetime/simple.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81288.268891.patch
Type: text/x-patch
Size: 22037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200605/5d73e7f9/attachment-0001.bin>
More information about the libcxx-commits
mailing list