aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2023-07-25 17:21:16 -0700
committerTobias Hieta <tobias@hieta.se>2023-07-27 15:29:23 +0200
commitcd2570ae9cdd399e54af029cf1dc51350462d2fd (patch)
treec6e37d3fa536e83571843d2db97e79431de30946 /llvm
parent52647ad0275c9bf76a78b6cb2575fd0be697819f (diff)
downloadllvm-cd2570ae9cdd399e54af029cf1dc51350462d2fd.zip
llvm-cd2570ae9cdd399e54af029cf1dc51350462d2fd.tar.gz
llvm-cd2570ae9cdd399e54af029cf1dc51350462d2fd.tar.bz2
[Support] Remove llvm::is_trivially_{copy/move}_constructible
This restores D132311, which was reverted in 29c841ce93e087fa4e0c5f3abae94edd460bc24a (Sep 2022) due to certain files not buildable with GCC 7.3.0. The previous attempt was reverted by 6cd9608fb37ca2418fb44b57ec955bb5efe10689 (Dec 2020). This time, GCC 7.3.0 has existing build errors for a long time due to structured bindings for many files, e.g. ``` llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9098:13: error: cannot decompose class type ‘std::pair<llvm::Value*, const llvm::SCEV*>’: both it and it s base class ‘std::pair<llvm::Value*, const llvm::SCEV*>’ have non-static data members for (auto [_, Stride] : Legal->getLAI()->getSymbolicStrides()) { ^~~~~~~~~~~ ``` ... and also some `error: duplicate initialization of` instances due to llvm/Transforms/IPO/Attributor.h. --- GCC 7.5.0 has a bug that, without this change, certain `SmallVector` with a `std::pair` element type like `SmallVector<std::pair<Instruction * const, Info>, 0> X;` lead to spurious ``` /tmp/opt/gcc-7.5.0/include/c++/7.5.0/type_traits:878:48: error: constructor required before non-static data member for ‘...’ has been parsed ``` Switching to std::is_trivially_{copy/move}_constructible fixes the error. (cherry picked from commit 6a684dbc4433a33e5f94fb15c9e378a2408021e0)
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/ADT/FunctionExtras.h12
-rw-r--r--llvm/include/llvm/ADT/SmallVector.h4
-rw-r--r--llvm/include/llvm/Support/type_traits.h38
-rw-r--r--llvm/unittests/Support/TypeTraitsTest.cpp4
4 files changed, 10 insertions, 48 deletions
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 53de2cb..4cf1de4 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -59,7 +59,7 @@ namespace detail {
template <typename T>
using EnableIfTrivial =
- std::enable_if_t<llvm::is_trivially_move_constructible<T>::value &&
+ std::enable_if_t<std::is_trivially_move_constructible<T>::value &&
std::is_trivially_destructible<T>::value>;
template <typename CallableT, typename ThisT>
using EnableUnlessSameType =
@@ -99,11 +99,11 @@ protected:
template <typename T> struct AdjustedParamTBase {
static_assert(!std::is_reference<T>::value,
"references should be handled by template specialization");
- using type = std::conditional_t<
- llvm::is_trivially_copy_constructible<T>::value &&
- llvm::is_trivially_move_constructible<T>::value &&
- IsSizeLessThanThresholdT<T>::value,
- T, T &>;
+ using type =
+ std::conditional_t<std::is_trivially_copy_constructible<T>::value &&
+ std::is_trivially_move_constructible<T>::value &&
+ IsSizeLessThanThresholdT<T>::value,
+ T, T &>;
};
// This specialization ensures that 'AdjustedParam<V<T>&>' or
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 93d9491..53a107b 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -326,8 +326,8 @@ public:
/// copy these types with memcpy, there is no way for the type to observe this.
/// This catches the important case of std::pair<POD, POD>, which is not
/// trivially assignable.
-template <typename T, bool = (is_trivially_copy_constructible<T>::value) &&
- (is_trivially_move_constructible<T>::value) &&
+template <typename T, bool = (std::is_trivially_copy_constructible<T>::value) &&
+ (std::is_trivially_move_constructible<T>::value) &&
std::is_trivially_destructible<T>::value>
class SmallVectorTemplateBase : public SmallVectorTemplateCommon<T> {
friend class SmallVectorTemplateCommon<T>;
diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h
index 86f07c1..3fd158d 100644
--- a/llvm/include/llvm/Support/type_traits.h
+++ b/llvm/include/llvm/Support/type_traits.h
@@ -69,21 +69,6 @@ struct const_pointer_or_const_ref<T, std::enable_if_t<std::is_pointer_v<T>>> {
};
namespace detail {
-/// Internal utility to detect trivial copy construction.
-template<typename T> union copy_construction_triviality_helper {
- T t;
- copy_construction_triviality_helper() = default;
- copy_construction_triviality_helper(const copy_construction_triviality_helper&) = default;
- ~copy_construction_triviality_helper() = default;
-};
-/// Internal utility to detect trivial move construction.
-template<typename T> union move_construction_triviality_helper {
- T t;
- move_construction_triviality_helper() = default;
- move_construction_triviality_helper(move_construction_triviality_helper&&) = default;
- ~move_construction_triviality_helper() = default;
-};
-
template<class T>
union trivial_helper {
T t;
@@ -91,29 +76,6 @@ union trivial_helper {
} // end namespace detail
-/// An implementation of `std::is_trivially_copy_constructible` since we have
-/// users with STLs that don't yet include it.
-template <typename T>
-struct is_trivially_copy_constructible
- : std::is_copy_constructible<
- ::llvm::detail::copy_construction_triviality_helper<T>> {};
-template <typename T>
-struct is_trivially_copy_constructible<T &> : std::true_type {};
-template <typename T>
-struct is_trivially_copy_constructible<T &&> : std::false_type {};
-
-/// An implementation of `std::is_trivially_move_constructible` since we have
-/// users with STLs that don't yet include it.
-template <typename T>
-struct is_trivially_move_constructible
- : std::is_move_constructible<
- ::llvm::detail::move_construction_triviality_helper<T>> {};
-template <typename T>
-struct is_trivially_move_constructible<T &> : std::true_type {};
-template <typename T>
-struct is_trivially_move_constructible<T &&> : std::true_type {};
-
-
template <typename T>
struct is_copy_assignable {
template<class F>
diff --git a/llvm/unittests/Support/TypeTraitsTest.cpp b/llvm/unittests/Support/TypeTraitsTest.cpp
index 229626c7..3220cc7 100644
--- a/llvm/unittests/Support/TypeTraitsTest.cpp
+++ b/llvm/unittests/Support/TypeTraitsTest.cpp
@@ -26,10 +26,10 @@ namespace triviality {
template <typename T, bool IsTriviallyCopyConstructible,
bool IsTriviallyMoveConstructible>
void TrivialityTester() {
- static_assert(llvm::is_trivially_copy_constructible<T>::value ==
+ static_assert(std::is_trivially_copy_constructible<T>::value ==
IsTriviallyCopyConstructible,
"Mismatch in expected trivial copy construction!");
- static_assert(llvm::is_trivially_move_constructible<T>::value ==
+ static_assert(std::is_trivially_move_constructible<T>::value ==
IsTriviallyMoveConstructible,
"Mismatch in expected trivial move construction!");