[PATCH] D47166: use zeroinitializer for (trailing zero portion of) large array initializers more reliably

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 22 12:53:39 PDT 2018


rsmith added inline comments.


================
Comment at: lib/CodeGen/CGExprConstant.cpp:675
+  // We have mixed types. Use a packed struct.
+  std::vector<llvm::Type *> Types;
+  Types.reserve(Elements.size());
----------------
rjmccall wrote:
> Why std::vector?
Only because this was extracted from the old version of the code. Switched to a `SmallVector`.


================
Comment at: test/CodeGenCXX/cxx11-initializer-aggregate.cpp:83
+  struct S1 data_7[1024 * 1024 * 512] = {{0}};
+
+  // This variable must be initialized elementwise.
----------------
sepavloff wrote:
> Array definitions:
> ```
> char data_8[1000 * 1000 * 1000] = {};
> int (&&data_9)[1000 * 1000 * 1000] = {0};
> ```
> also compile successfully with this patch and hang compiler without it.
I added these test cases, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47166





More information about the cfe-commits mailing list