[libcxx-commits] [libcxx] [libc++] Make _LIBCPP_ASSUME usable when it is appropriate (PR #91801)
David Benjamin via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 17 08:13:21 PDT 2024
================
@@ -23,17 +23,20 @@
: _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \
expression) " failed: " message "\n"))
-// TODO: __builtin_assume can currently inhibit optimizations. Until this has been fixed and we can add
-// assumptions without a clear optimization intent, disable that to avoid worsening the code generation.
-// See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a discussion.
-#if 0 && __has_builtin(__builtin_assume)
+// WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear
+// optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a
+// discussion.
+#if __has_builtin(__builtin_assume)
# define _LIBCPP_ASSUME(expression) \
(_LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \
__builtin_assume(static_cast<bool>(expression)) _LIBCPP_DIAGNOSTIC_POP)
#else
# define _LIBCPP_ASSUME(expression) ((void)0)
#endif
+// Historically, disabled assertions below expanded to `_LIBCPP_ASSUME`, but this both triggers the
----------------
davidben wrote:
Removed and rebased.
https://github.com/llvm/llvm-project/pull/91801
More information about the libcxx-commits
mailing list