diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -1548,23 +1548,18 @@ // Provide wrappers to std::sort which shuffle the elements before sorting // to help uncover non-deterministic behavior (PR35135). -template ::value, - int> = 0> +template inline void sort(IteratorTy Start, IteratorTy End) { + if constexpr (detail::sort_trivially_copyable::value) { + // Forward trivially copyable types to array_pod_sort. This avoids a large + // amount of code bloat for a minor performance hit. + array_pod_sort(Start, End); + } else { #ifdef EXPENSIVE_CHECKS - detail::presortShuffle(Start, End); + detail::presortShuffle(Start, End); #endif - std::sort(Start, End); -} - -// Forward trivially copyable types to array_pod_sort. This avoids a large -// amount of code bloat for a minor performance hit. -template ::value, - int> = 0> -inline void sort(IteratorTy Start, IteratorTy End) { - array_pod_sort(Start, End); + std::sort(Start, End); + } } template inline void sort(Container &&C) {