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

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 22 10:34:05 PDT 2018


sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

Now I understand your idea about moving the logic to `tryEmitPrivateForMemory`. Indeed it is more general and consistent solution.
Thank you.



================
Comment at: lib/CodeGen/CGExprConstant.cpp:643
+                  llvm::Constant *Filler) {
+  // Figre out how long the initial prefix of non-zero elements is.
+  unsigned NonzeroLength = ArrayBound;
----------------
s/Figre/Figure/ ?


================
Comment at: lib/CodeGen/CGExprConstant.cpp:903
     SmallVector<llvm::Constant*, 16> Elts;
-    Elts.reserve(std::max(NumInitableElts, NumElements));
+    if (fillC && fillC->isNullValue())
+      Elts.reserve(NumInitableElts + 1);
----------------
The check for `fillC != nullptr` here is redundant, it was checked few lines above.


================
Comment at: test/CodeGenCXX/cxx11-initializer-aggregate.cpp:83
+  struct S1 data_7[1024 * 1024 * 512] = {{0}};
+
+  // This variable must be initialized elementwise.
----------------
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.


Repository:
  rC Clang

https://reviews.llvm.org/D47166





More information about the cfe-commits mailing list