[Development] are clangs 3.5 new builtin_operator_(new/delete) also useable for Qt Container optimization?
Olivier Goffart
olivier at woboq.com
Thu Jul 17 12:20:56 CEST 2014
On Thursday 17 July 2014 10:27:39 Dennis Luehring wrote:
> these new builtins allows clang to optimize operator new/delete
> operations far better then before
>
> __builtin_operator_new
> __builtin_operator_delete
>
> patches in review for clang 3.5
> clang: http://reviews.llvm.org/rL210137
> libc++: http://reviews.llvm.org/rL210211
>
> the libc++ patch is very small and maybe the Qt container library
> can also benefit from an clang specific specialization
I'm afraid Qt containers can't fully enjoy those optimization:
QArrayData::allocate which is used by most of the container is not inline.
C++14 is allowing compiler to optimize allocation done with new or malloc (by
removing them).
But explicit call to "::operator new()" (used in allocators for example) are
still not allowed to be optimized because the standard require them to be able
to be replaced by the user.
But Qt don't use custom allocators. According to grep, the only place where
"operator new" is used directly in Qt is QSharedPointer[2]. And I believe it
is better to change the code to call the normal new. (I'm not sure why it's
done this way.)
So there is no place in Qt where this __builtin_operator_new make sens.
But thanks for the notification.
[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3664.html
[2]
http://code.woboq.org/qt5/qtbase/src/corelib/tools/qsharedpointer_impl.h.html#_ZN15QtSharedPointer33ExternalRefCountWithCustomDeleter6createEPT_T0_PFvPNS_20ExternalRefCountDataEE
--
Olivier
Woboq - Qt services and support - http://woboq.com - http://code.woboq.org
More information about the Development
mailing list