Skip to content

Commit d96c7f4

Browse files
committed
Revert "Revert "[ADT] Fix SmallVector unused template instantiation on 32-bit systems.""
This reverts commit ac2635e. Revert was too hasty, build was already broken.
1 parent 6a1ad76 commit d96c7f4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/lib/Support/SmallVector.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,18 @@ void SmallVectorBase<Size_T>::grow_pod(void *FirstEl, size_t MinCapacity,
7878
}
7979

8080
template class llvm::SmallVectorBase<uint32_t>;
81+
82+
// Disable the uint64_t instantiation for 32-bit builds.
83+
// Both uint32_t and uint64_t instantations are needed for 64-bit builds.
84+
// This instantiation will never be used in 32-bit builds, and will cause
85+
// warnings when sizeof(Size_T) > sizeof(size_t).
86+
#if SIZE_MAX > UINT32_MAX
8187
template class llvm::SmallVectorBase<uint64_t>;
88+
89+
// Assertions to ensure this #if stays in sync with SmallVectorSizeType.
90+
static_assert(sizeof(SmallVectorSizeType<char>) == sizeof(uint64_t),
91+
"Expected SmallVectorBase<uint64_t> variant to be in use.");
92+
#else
93+
static_assert(sizeof(SmallVectorSizeType<char>) == sizeof(uint32_t),
94+
"Expected SmallVectorBase<uint32_t> variant to be in use.");
95+
#endif

0 commit comments

Comments
 (0)