From f4c82cffc6882715045d97f72d989703b643f4ad Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 23 Jun 2018 18:39:44 +0000 Subject: ADT: Use EBO to shrink SmallVector size 1 SmallVectorStorage is empty when its size is 1; use inheritance so that the empty base class optimization kicks in. llvm-svn: 335421 --- llvm/lib/Support/SmallVector.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Support/SmallVector.cpp') diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp index ccab4a125aa..e8e3498968c 100644 --- a/llvm/lib/Support/SmallVector.cpp +++ b/llvm/lib/Support/SmallVector.cpp @@ -14,6 +14,10 @@ #include "llvm/ADT/SmallVector.h" using namespace llvm; +// Check that no bytes are wasted. +static_assert(sizeof(SmallVector) == sizeof(void *) * 4, + "wasted space in SmallVector size 1; missing EBO?"); + /// grow_pod - This is an implementation of the grow() method which only works /// on POD-like datatypes and is out of line to reduce code duplication. void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSizeInBytes, -- cgit v1.2.3