Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

This patch moves IsSizeLessThanThresholdT into AdjustedParamTBase, the
sole user of the helper, while switching to a type alias.

Aside from moving the helper closer to where it's used, another
benefit is that we can assume that T is a complete type inside
AdjustedParamTBase. Note that sizeof(T) serves as a check for a
complete type. Inside AdjustedParamTBase, we only pass complete
non-void types to:

std::is_trivially_copy_constructible
std::is_trivially_move_constructible

so we can safely drop the fallback case implemented with
std::false_type.

This patch moves IsSizeLessThanThresholdT into AdjustedParamTBase, the
sole user of the helper, while switching to a type alias.

Aside from moving the helper closer to where it's used, another
benefit is that we can assume that T is a complete type inside
AdjustedParamTBase.  Note that sizeof(T) serves as a check for a
complete type.  Inside AdjustedParamTBase, we only pass complete
non-void types to:

  std::is_trivially_copy_constructible<T>
  std::is_trivially_move_constructible<T>

so we can safely drop the fallback case implemented with
std::false_type.
@llvmbot
Copy link
Member

llvmbot commented Sep 20, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

This patch moves IsSizeLessThanThresholdT into AdjustedParamTBase, the
sole user of the helper, while switching to a type alias.

Aside from moving the helper closer to where it's used, another
benefit is that we can assume that T is a complete type inside
AdjustedParamTBase. Note that sizeof(T) serves as a check for a
complete type. Inside AdjustedParamTBase, we only pass complete
non-void types to:

std::is_trivially_copy_constructible<T>
std::is_trivially_move_constructible<T>

so we can safely drop the fallback case implemented with
std::false_type.


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

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/FunctionExtras.h (+3-7)
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index d92868e3715f4..e45d507bfd4bf 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -82,13 +82,6 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
   static constexpr size_t InlineStorageSize = sizeof(void *) * 3;
   static constexpr size_t InlineStorageAlign = alignof(void *);
 
-  template <typename T, class = void>
-  struct IsSizeLessThanThresholdT : std::false_type {};
-
-  template <typename T>
-  struct IsSizeLessThanThresholdT<
-      T, std::enable_if_t<sizeof(T) <= 2 * sizeof(void *)>> : std::true_type {};
-
   // Provide a type function to map parameters that won't observe extra copies
   // or moves and which are small enough to likely pass in register to values
   // and all other types to l-value reference types. We use this to compute the
@@ -101,6 +94,9 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
   template <typename T> struct AdjustedParamTBase {
     static_assert(!std::is_reference<T>::value,
                   "references should be handled by template specialization");
+    template <typename U>
+    using IsSizeLessThanThresholdT =
+        std::bool_constant<sizeof(U) <= 2 * sizeof(void *)>;
     using type =
         std::conditional_t<std::is_trivially_copy_constructible<T>::value &&
                                std::is_trivially_move_constructible<T>::value &&

@kazutakahirata kazutakahirata merged commit cb78bf6 into llvm:main Sep 20, 2025
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250919_10TMP_ADT_FunctionExtras_IsSizeLessThanThresholdT branch September 20, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants