[llvm] [ADT] Always use 32-bit size type for SmallVector with 16-bit elements (PR #95536)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 06:04:00 PDT 2024
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/95536
SmallVector has a special case to allow vector of char to exceed 4 GB in
size on 64-bit hosts. Apply this special case only for 8-bit element
types, instead of all element types < 32 bits.
This makes SmallVector<MCPhysReg> more compact because MCPhysReg is
uint16_t.
>From 01d0beab64ec3b116af082cf3c8425915f4e82b4 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Fri, 14 Jun 2024 13:58:27 +0100
Subject: [PATCH] [ADT] Always use 32-bit size type for SmallVector with 16-bit
elements
SmallVector has a special case to allow vector of char to exceed 4 GB in
size on 64-bit hosts. Apply this special case only for 8-bit element
types, instead of all element types < 32 bits.
This makes SmallVector<MCPhysReg> more compact because MCPhysReg is
uint16_t.
---
llvm/include/llvm/ADT/SmallVector.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 09676d792dfeb..d7e889cc7b1e4 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -116,8 +116,7 @@ template <class Size_T> class SmallVectorBase {
template <class T>
using SmallVectorSizeType =
- std::conditional_t<sizeof(T) < 4 && sizeof(void *) >= 8, uint64_t,
- uint32_t>;
+ std::conditional_t<sizeof(T) == 1, uintptr_t, uint32_t>;
/// Figure out the offset of the first element.
template <class T, typename = void> struct SmallVectorAlignmentAndSize {
More information about the llvm-commits
mailing list