forked from OSchip/llvm-project
[libcxx] Add flag to disable __builtin_assume in _LIBCPP_ASSERT
Introduce _LIBCPP_ASSERTIONS_DISABLE_ASSUME which makes _LIBCPP_ASSERT not call __builtin_assume when _LIBCPP_ENABLE_ASSERTIONS == 0. Calling __builtin_assume was introduced in D122397. __builtin_assume is generally supposed to improve optimizations, but can cause regressions when LLVM has trouble handling the calls to `llvm.assume()` (see comments in D122397). Reviewed By: philnik Differential Revision: https://reviews.llvm.org/D123175
This commit is contained in:
parent
6733590db2
commit
0a77e63322
|
@ -38,16 +38,14 @@
|
|||
(__builtin_expect(static_cast<bool>(expression), 1) ? \
|
||||
(void)0 : \
|
||||
::std::__libcpp_assertion_handler(__FILE__, __LINE__, #expression, message))
|
||||
#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
|
||||
# define _LIBCPP_ASSERT(expression, message) \
|
||||
(_LIBCPP_DIAGNOSTIC_PUSH \
|
||||
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \
|
||||
__builtin_assume(static_cast<bool>(expression)) \
|
||||
_LIBCPP_DIAGNOSTIC_POP)
|
||||
#else
|
||||
# if __has_builtin(__builtin_assume)
|
||||
# define _LIBCPP_ASSERT(expression, message) \
|
||||
(_LIBCPP_DIAGNOSTIC_PUSH \
|
||||
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \
|
||||
__builtin_assume(static_cast<bool>(expression)) \
|
||||
_LIBCPP_DIAGNOSTIC_POP)
|
||||
# else
|
||||
# define _LIBCPP_ASSERT(expression, message) ((void)0)
|
||||
# endif
|
||||
# define _LIBCPP_ASSERT(expression, message) ((void)0)
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0
|
||||
// RUN: %{run}
|
||||
|
||||
// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0 -D_LIBCPP_ASSERTIONS_DISABLE_ASSUME
|
||||
// RUN: %{run}
|
||||
|
||||
// We flag uses of the assertion handler in older dylibs at compile-time to avoid runtime
|
||||
// failures when back-deploying.
|
||||
// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
|
||||
|
|
Loading…
Reference in New Issue