[llvm] d96c7f4 - Revert "Revert "[ADT] Fix SmallVector unused template instantiation on 32-bit systems.""

Andrew Browne via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 17:18:56 PDT 2020


Author: Andrew Browne
Date: 2020-04-30T17:18:14-07:00
New Revision: d96c7f413f35ee6f343dfdcd7c5c11ea3e724e16

URL: https://github.com/llvm/llvm-project/commit/d96c7f413f35ee6f343dfdcd7c5c11ea3e724e16
DIFF: https://github.com/llvm/llvm-project/commit/d96c7f413f35ee6f343dfdcd7c5c11ea3e724e16.diff

LOG: Revert "Revert "[ADT] Fix SmallVector unused template instantiation on 32-bit systems.""

This reverts commit ac2635e457d53b80b0a6f73a5041767197643aae.

Revert was too hasty, build was already broken.

Added: 
    

Modified: 
    llvm/lib/Support/SmallVector.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp
index 776b0981409f..0c9ac83f300a 100644
--- a/llvm/lib/Support/SmallVector.cpp
+++ b/llvm/lib/Support/SmallVector.cpp
@@ -78,4 +78,18 @@ void SmallVectorBase<Size_T>::grow_pod(void *FirstEl, size_t MinCapacity,
 }
 
 template class llvm::SmallVectorBase<uint32_t>;
+
+// Disable the uint64_t instantiation for 32-bit builds.
+// Both uint32_t and uint64_t instantations are needed for 64-bit builds.
+// This instantiation will never be used in 32-bit builds, and will cause
+// warnings when sizeof(Size_T) > sizeof(size_t).
+#if SIZE_MAX > UINT32_MAX
 template class llvm::SmallVectorBase<uint64_t>;
+
+// Assertions to ensure this #if stays in sync with SmallVectorSizeType.
+static_assert(sizeof(SmallVectorSizeType<char>) == sizeof(uint64_t),
+              "Expected SmallVectorBase<uint64_t> variant to be in use.");
+#else
+static_assert(sizeof(SmallVectorSizeType<char>) == sizeof(uint32_t),
+              "Expected SmallVectorBase<uint32_t> variant to be in use.");
+#endif


        


More information about the llvm-commits mailing list