From: Chandler Carruth Date: Sun, 9 Jan 2011 11:29:57 +0000 (+0000) Subject: Another missed memset in std::vector initialization. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=694d753b09c8f76f0ded5f2d650446bf021e9e8a;p=oota-llvm.git Another missed memset in std::vector initialization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123116 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/README.txt b/lib/Target/README.txt index 7d90795aa3b..9ecd2ffc199 100644 --- a/lib/Target/README.txt +++ b/lib/Target/README.txt @@ -2230,3 +2230,22 @@ Then, the really painful one is the second memset, of the same memory, to the same value. //===---------------------------------------------------------------------===// + +clang -O3 -fno-exceptions currently compiles this code: + +struct S { + unsigned short m1, m2; + unsigned char m3, m4; +}; + +void f(int N) { + std::vector v(N); + extern void sink(void*); sink(&v); +} + +into poor code for zero-initializing 'v' when N is >0. The problem is that +S is only 6 bytes, but each element is 8 byte-aligned. We generate a loop and +4 stores on each iteration. If the struct were 8 bytes, this gets turned into +a memset. + +//===---------------------------------------------------------------------===//