Skip to content

[libc++] Use __array_rank in Clang versions without any known bugs #136103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

philnik777
Copy link
Contributor

There was a bug in the implementation of __array_rank until LLVM 20 which prevented us from using the builtin. Since the bug has been fixed now we can enable the use and remove the generic implementation in a few releases.

@philnik777 philnik777 marked this pull request as ready for review April 25, 2025 08:36
@philnik777 philnik777 requested a review from a team as a code owner April 25, 2025 08:36
@philnik777 philnik777 merged commit 911cb60 into llvm:main Apr 25, 2025
85 checks passed
@philnik777 philnik777 deleted the enable_array_rank branch April 25, 2025 08:36
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Apr 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 25, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

There was a bug in the implementation of __array_rank until LLVM 20 which prevented us from using the builtin. Since the bug has been fixed now we can enable the use and remove the generic implementation in a few releases.


Full diff: https://github.com/llvm/llvm-project/pull/136103.diff

1 Files Affected:

  • (modified) libcxx/include/__type_traits/rank.h (+3-3)
diff --git a/libcxx/include/__type_traits/rank.h b/libcxx/include/__type_traits/rank.h
index 55c78ea044b37..5196b62949fa2 100644
--- a/libcxx/include/__type_traits/rank.h
+++ b/libcxx/include/__type_traits/rank.h
@@ -19,11 +19,11 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-// TODO: Enable using the builtin __array_rank when https://llvm.org/PR57133 is resolved
-#if __has_builtin(__array_rank) && 0
+#if __has_builtin(__array_rank) && !defined(_LIBCPP_COMPILER_CLANG_BASED) ||                                           \
+    (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2001)
 
 template <class _Tp>
-struct rank : integral_constant<size_t, __array_rank(_Tp)> {};
+struct _LIBCPP_NO_SPECIALIZATIONS rank : integral_constant<size_t, __array_rank(_Tp)> {};
 
 #else
 

IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…lvm#136103)

There was a bug in the implementation of `__array_rank` until LLVM 20
which prevented us from using the builtin. Since the bug has been fixed
now we can enable the use and remove the generic implementation in a few
releases.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…lvm#136103)

There was a bug in the implementation of `__array_rank` until LLVM 20
which prevented us from using the builtin. Since the bug has been fixed
now we can enable the use and remove the generic implementation in a few
releases.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
…lvm#136103)

There was a bug in the implementation of `__array_rank` until LLVM 20
which prevented us from using the builtin. Since the bug has been fixed
now we can enable the use and remove the generic implementation in a few
releases.
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
…lvm#136103)

There was a bug in the implementation of `__array_rank` until LLVM 20
which prevented us from using the builtin. Since the bug has been fixed
now we can enable the use and remove the generic implementation in a few
releases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants