llvm-capstone/libcxx
Eric Fiselier 8baf83839e Fix PR27658 - Make ~mutex trivial when possible.
Currently std::mutex has a constexpr constructor, but a non-trivial
destruction.

The constexpr constructor is required to ensure the construction of a
mutex with static storage duration happens at compile time, during
constant initialization, and not during dynamic initialization.
This means that static mutex's are always initialized and can be used
safely during dynamic initialization without the "static initialization
order fiasco".

A trivial destructor is important for similar reasons. If a mutex is
used during dynamic initialization it might also be used during program
termination. If a static mutex has a non-trivial destructor it will be
invoked during termination. This can introduce the "static
deinitialization order fiasco".

Additionally, function-local statics emit a guard variable around
non-trivially destructible types. This results in horrible codegen and
adds a runtime cost to every call to that function. non-local static's
also result in slightly worse codegen but it's not as big of a problem.

Example codegen can be found here: https://goo.gl/3CSzbM

Note: This optimization is not safe with every pthread implementation.
Some implementations allocate on the first call to pthread_mutex_lock
and free the allocation in pthread_mutex_destroy.

Also, changing the triviality of the destructor is not an ABI break.
At least to the best of my knowledge :-)

llvm-svn: 365273
2019-07-07 01:20:54 +00:00
..
benchmarks
cmake
docs
fuzzing
include Fix PR27658 - Make ~mutex trivial when possible. 2019-07-07 01:20:54 +00:00
lib
src Fix PR27658 - Make ~mutex trivial when possible. 2019-07-07 01:20:54 +00:00
test Fix PR27658 - Make ~mutex trivial when possible. 2019-07-07 01:20:54 +00:00
utils
www
.arcconfig
.clang-format
.gitignore
appveyor-reqs-install.cmd
appveyor.yml
CMakeLists.txt
CREDITS.TXT
LICENSE.TXT
NOTES.TXT
TODO.TXT