-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Revert "[ADT] Always use 32-bit size type for SmallVector with 16-bit elements" #96826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… element…" This reverts commit 2582d11.
@llvm/pr-subscribers-llvm-support Author: Chelsea Cassanova (chelcassanova) ChangesReverts llvm/llvm-project#95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398 Full diff: https://github.com/llvm/llvm-project/pull/96826.diff 2 Files Affected:
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index db34b16ecf9e7..09676d792dfeb 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -116,7 +116,8 @@ template <class Size_T> class SmallVectorBase {
template <class T>
using SmallVectorSizeType =
- std::conditional_t<sizeof(T) == 1, size_t, uint32_t>;
+ std::conditional_t<sizeof(T) < 4 && sizeof(void *) >= 8, uint64_t,
+ uint32_t>;
/// Figure out the offset of the first element.
template <class T, typename = void> struct SmallVectorAlignmentAndSize {
diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp
index e77b747984173..b6ce37842040b 100644
--- a/llvm/lib/Support/SmallVector.cpp
+++ b/llvm/lib/Support/SmallVector.cpp
@@ -37,7 +37,9 @@ struct Struct32B {
#pragma GCC diagnostic pop
#endif
}
-
+static_assert(sizeof(SmallVector<void *, 0>) ==
+ sizeof(unsigned) * 2 + sizeof(void *),
+ "wasted space in SmallVector size 0");
static_assert(alignof(SmallVector<Struct16B, 0>) >= alignof(Struct16B),
"wrong alignment for 16-byte aligned T");
static_assert(alignof(SmallVector<Struct32B, 0>) >= alignof(Struct32B),
@@ -46,19 +48,13 @@ static_assert(sizeof(SmallVector<Struct16B, 0>) >= alignof(Struct16B),
"missing padding for 16-byte aligned T");
static_assert(sizeof(SmallVector<Struct32B, 0>) >= alignof(Struct32B),
"missing padding for 32-byte aligned T");
-
-static_assert(sizeof(SmallVector<void *, 0>) ==
- sizeof(unsigned) * 2 + sizeof(void *),
- "wasted space in SmallVector size 0");
static_assert(sizeof(SmallVector<void *, 1>) ==
sizeof(unsigned) * 2 + sizeof(void *) * 2,
"wasted space in SmallVector size 1");
+
static_assert(sizeof(SmallVector<char, 0>) ==
sizeof(void *) * 2 + sizeof(void *),
"1 byte elements have word-sized type for size and capacity");
-static_assert(sizeof(SmallVector<int16_t, 0>) ==
- sizeof(unsigned) * 2 + sizeof(void *),
- "2 byte elements have 32-bit type for size and capacity");
/// Report that MinSize doesn't fit into this vector's size type. Throws
/// std::length_error or calls report_fatal_error.
|
@llvm/pr-subscribers-llvm-adt Author: Chelsea Cassanova (chelcassanova) ChangesReverts llvm/llvm-project#95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398 Full diff: https://github.com/llvm/llvm-project/pull/96826.diff 2 Files Affected:
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index db34b16ecf9e7..09676d792dfeb 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -116,7 +116,8 @@ template <class Size_T> class SmallVectorBase {
template <class T>
using SmallVectorSizeType =
- std::conditional_t<sizeof(T) == 1, size_t, uint32_t>;
+ std::conditional_t<sizeof(T) < 4 && sizeof(void *) >= 8, uint64_t,
+ uint32_t>;
/// Figure out the offset of the first element.
template <class T, typename = void> struct SmallVectorAlignmentAndSize {
diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp
index e77b747984173..b6ce37842040b 100644
--- a/llvm/lib/Support/SmallVector.cpp
+++ b/llvm/lib/Support/SmallVector.cpp
@@ -37,7 +37,9 @@ struct Struct32B {
#pragma GCC diagnostic pop
#endif
}
-
+static_assert(sizeof(SmallVector<void *, 0>) ==
+ sizeof(unsigned) * 2 + sizeof(void *),
+ "wasted space in SmallVector size 0");
static_assert(alignof(SmallVector<Struct16B, 0>) >= alignof(Struct16B),
"wrong alignment for 16-byte aligned T");
static_assert(alignof(SmallVector<Struct32B, 0>) >= alignof(Struct32B),
@@ -46,19 +48,13 @@ static_assert(sizeof(SmallVector<Struct16B, 0>) >= alignof(Struct16B),
"missing padding for 16-byte aligned T");
static_assert(sizeof(SmallVector<Struct32B, 0>) >= alignof(Struct32B),
"missing padding for 32-byte aligned T");
-
-static_assert(sizeof(SmallVector<void *, 0>) ==
- sizeof(unsigned) * 2 + sizeof(void *),
- "wasted space in SmallVector size 0");
static_assert(sizeof(SmallVector<void *, 1>) ==
sizeof(unsigned) * 2 + sizeof(void *) * 2,
"wasted space in SmallVector size 1");
+
static_assert(sizeof(SmallVector<char, 0>) ==
sizeof(void *) * 2 + sizeof(void *),
"1 byte elements have word-sized type for size and capacity");
-static_assert(sizeof(SmallVector<int16_t, 0>) ==
- sizeof(unsigned) * 2 + sizeof(void *),
- "2 byte elements have 32-bit type for size and capacity");
/// Report that MinSize doesn't fit into this vector's size type. Throws
/// std::length_error or calls report_fatal_error.
|
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
… elements" (llvm#96826) Reverts llvm#95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
… elements" (#96826) Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
… elements" (llvm#96826) Reverts llvm#95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398
Reverts #95536, this is breaking macOS GreenDragon buildbots on arm64 and x86_64 https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6522/console, also breaks the Darwin LLVM buildbots: https://lab.llvm.org/buildbot/#/builders/23/builds/398