[libcxx-commits] [PATCH] D153968: [libc++] Stop using __builtin_assume in _LIBCPP_ASSERT
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 29 07:04:12 PDT 2023
ldionne updated this revision to Diff 535777.
ldionne added a comment.
Fix [[maybe_unused]] issue on Windows.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153968/new/
https://reviews.llvm.org/D153968
Files:
libcxx/include/__assert
libcxx/src/filesystem/posix_compat.h
Index: libcxx/src/filesystem/posix_compat.h
===================================================================
--- libcxx/src/filesystem/posix_compat.h
+++ libcxx/src/filesystem/posix_compat.h
@@ -383,7 +383,7 @@
inline wchar_t *getcwd(wchar_t *buff, size_t size) { return _wgetcwd(buff, size); }
-inline wchar_t *realpath(const wchar_t *path, wchar_t *resolved_name) {
+inline wchar_t *realpath(const wchar_t *path, [[maybe_unused]] wchar_t *resolved_name) {
// Only expected to be used with us allocating the buffer.
_LIBCPP_ASSERT_UNCATEGORIZED(resolved_name == nullptr,
"Windows realpath() assumes a null resolved_name");
Index: libcxx/include/__assert
===================================================================
--- libcxx/include/__assert
+++ libcxx/include/__assert
@@ -38,7 +38,10 @@
? (void)0 \
: _LIBCPP_VERBOSE_ABORT( \
"%s:%d: assertion %s failed: %s\n", __builtin_FILE(), __builtin_LINE(), #expression, message))
-#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
+// 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.
+#elif 0 && __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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153968.535777.patch
Type: text/x-patch
Size: 1957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230629/065dad19/attachment-0001.bin>
More information about the libcxx-commits
mailing list