Use __builtin_operator_new/__builtin_operator_delete when available. This

allows allocations and deallocations to be optimized out.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@210211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Richard Smith
2014-06-04 19:54:15 +00:00
parent 0707b67ac3
commit 73c1fce21c
6 changed files with 55 additions and 26 deletions

View File

@@ -147,4 +147,24 @@ inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _N
inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {}
inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {}
_LIBCPP_BEGIN_NAMESPACE_STD
inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) {
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
return ::operator new(__size);
#else
return __builtin_operator_new(__size);
#endif
}
inline _LIBCPP_INLINE_VISIBILITY void __deallocate(void *__ptr) {
#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
::operator delete(__ptr);
#else
__builtin_operator_delete(__ptr);
#endif
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_NEW