[llvm] 36357c9 - Remove llvm::is_trivially_copyable (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 21 10:39:32 PDT 2022


Author: Kazu Hirata
Date: 2022-08-21T10:39:19-07:00
New Revision: 36357c967cdb9006dd7de9be0dd52068da2a4f96

URL: https://github.com/llvm/llvm-project/commit/36357c967cdb9006dd7de9be0dd52068da2a4f96
DIFF: https://github.com/llvm/llvm-project/commit/36357c967cdb9006dd7de9be0dd52068da2a4f96.diff

LOG: Remove llvm::is_trivially_copyable (NFC)

This patch removes llvm::is_trivially_copyable as it seems to be dead.
Once I remove it, HAVE_STD_IS_TRIVIALLY_COPYABLE has no users, so this
patch removes the macro also.

The comment on llvm::is_trivially_copyable mentions GCC 4.9, but note
that we now require GCC 7.1 or higher.

Differential Revision: https://reviews.llvm.org/D132328

Added: 
    

Modified: 
    llvm/cmake/config-ix.cmake
    llvm/include/llvm/ADT/PointerIntPair.h
    llvm/include/llvm/Config/config.h.cmake
    llvm/include/llvm/Support/type_traits.h
    llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
    utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
    utils/bazel/llvm_configs/config.h.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 6beb25017ee50..165a2144cd1be 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -398,15 +398,6 @@ endif()
 
 check_symbol_exists(proc_pid_rusage "libproc.h" HAVE_PROC_PID_RUSAGE)
 
-# Whether we can use std::is_trivially_copyable to verify llvm::is_trivially_copyable.
-CHECK_CXX_SOURCE_COMPILES("
-#include <type_traits>
-struct T { int val; };
-static_assert(std::is_trivially_copyable<T>::value, \"ok\");
-int main() { return 0;}
-" HAVE_STD_IS_TRIVIALLY_COPYABLE)
-
-
 # Define LLVM_HAS_ATOMICS if gcc or MSVC atomic builtins are supported.
 include(CheckAtomic)
 

diff  --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
index 7d10b2a6dd149..119285087957f 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -128,19 +128,6 @@ class PointerIntPair {
   }
 };
 
-// Specialize is_trivially_copyable to avoid limitation of llvm::is_trivially_copyable
-// when compiled with gcc 4.9.
-template <typename PointerTy, unsigned IntBits, typename IntType,
-          typename PtrTraits,
-          typename Info>
-struct is_trivially_copyable<PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>> : std::true_type {
-#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
-  static_assert(std::is_trivially_copyable<PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>>::value,
-                "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable");
-#endif
-};
-
-
 template <typename PointerT, unsigned IntBits, typename PtrTraits>
 struct PointerIntPairInfo {
   static_assert(PtrTraits::NumLowBitsAvailable <

diff  --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index 21ce3a94a5edb..3543e6fc29944 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -320,9 +320,6 @@
 /* Define to the vendor of this package. */
 #cmakedefine PACKAGE_VENDOR "${PACKAGE_VENDOR}"
 
-/* Define if std::is_trivially_copyable is supported */
-#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE ${HAVE_STD_IS_TRIVIALLY_COPYABLE}
-
 /* Define to a function implementing stricmp */
 #cmakedefine stricmp ${stricmp}
 

diff  --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h
index 534ad8c7eac93..3a9169beeb5f4 100644
--- a/llvm/include/llvm/Support/type_traits.h
+++ b/llvm/include/llvm/Support/type_traits.h
@@ -93,61 +93,6 @@ struct is_move_assignable {
     static constexpr bool value = decltype(get((T*)nullptr))::value;
 };
 
-
-// An implementation of `std::is_trivially_copyable` since STL version
-// is not equally supported by all compilers, especially GCC 4.9.
-// Uniform implementation of this trait is important for ABI compatibility
-// as it has an impact on SmallVector's ABI (among others).
-template <typename T>
-class is_trivially_copyable {
-
-  // copy constructors
-  static constexpr bool has_trivial_copy_constructor =
-      std::is_copy_constructible<detail::trivial_helper<T>>::value;
-  static constexpr bool has_deleted_copy_constructor =
-      !std::is_copy_constructible<T>::value;
-
-  // move constructors
-  static constexpr bool has_trivial_move_constructor =
-      std::is_move_constructible<detail::trivial_helper<T>>::value;
-  static constexpr bool has_deleted_move_constructor =
-      !std::is_move_constructible<T>::value;
-
-  // copy assign
-  static constexpr bool has_trivial_copy_assign =
-      is_copy_assignable<detail::trivial_helper<T>>::value;
-  static constexpr bool has_deleted_copy_assign =
-      !is_copy_assignable<T>::value;
-
-  // move assign
-  static constexpr bool has_trivial_move_assign =
-      is_move_assignable<detail::trivial_helper<T>>::value;
-  static constexpr bool has_deleted_move_assign =
-      !is_move_assignable<T>::value;
-
-  // destructor
-  static constexpr bool has_trivial_destructor =
-      std::is_destructible<detail::trivial_helper<T>>::value;
-
-  public:
-
-  static constexpr bool value =
-      has_trivial_destructor &&
-      (has_deleted_move_assign || has_trivial_move_assign) &&
-      (has_deleted_move_constructor || has_trivial_move_constructor) &&
-      (has_deleted_copy_assign || has_trivial_copy_assign) &&
-      (has_deleted_copy_constructor || has_trivial_copy_constructor);
-
-#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE
-  static_assert(value == std::is_trivially_copyable<T>::value,
-                "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable");
-#endif
-};
-template <typename T>
-class is_trivially_copyable<T*> : public std::true_type {
-};
-
-
 } // end namespace llvm
 
 #endif // LLVM_SUPPORT_TYPE_TRAITS_H

diff  --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
index 897364f007410..d4984b2c40fec 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -95,7 +95,6 @@ write_cmake_config("config") {
     "HAVE_LIBPSAPI=",
     "HAVE_MALLCTL=",
     "HAVE_SIGNAL_H=1",
-    "HAVE_STD_IS_TRIVIALLY_COPYABLE=1",
     "HAVE_STRERROR=1",
     "HAVE_SYS_STAT_H=1",
     "HAVE_SYS_TYPES_H=1",

diff  --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
index 03eb4ff2c4562..167cdfcbdce95 100644
--- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
+++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
@@ -333,9 +333,6 @@
 /* Define to the vendor of this package. */
 /* #undef PACKAGE_VENDOR */
 
-/* Define if std::is_trivially_copyable is supported */
-#define HAVE_STD_IS_TRIVIALLY_COPYABLE 1
-
 /* Define to a function implementing stricmp */
 /* stricmp defined conditionally below. */
 

diff  --git a/utils/bazel/llvm_configs/config.h.cmake b/utils/bazel/llvm_configs/config.h.cmake
index 21ce3a94a5edb..3543e6fc29944 100644
--- a/utils/bazel/llvm_configs/config.h.cmake
+++ b/utils/bazel/llvm_configs/config.h.cmake
@@ -320,9 +320,6 @@
 /* Define to the vendor of this package. */
 #cmakedefine PACKAGE_VENDOR "${PACKAGE_VENDOR}"
 
-/* Define if std::is_trivially_copyable is supported */
-#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE ${HAVE_STD_IS_TRIVIALLY_COPYABLE}
-
 /* Define to a function implementing stricmp */
 #cmakedefine stricmp ${stricmp}
 


        


More information about the llvm-commits mailing list