[PATCH] D43181: [CodeGen] Initialize large arrays by copying from a global

Ivan Kosarev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 07:54:42 PST 2018


kosarev added inline comments.


================
Comment at: lib/CodeGen/CGExprAgg.cpp:421
+  // with explicit initializers should be large enough.
+  if (NumInitElements > 8 && elementType->isBuiltinType()) {
+    CodeGen::CodeGenModule &CGM = CGF.CGM;
----------------
rjmccall wrote:
> Is there a good reason to use an element-count heuristic instead of a total-size heuristic here?
> 
> Why only builtin types?  That seems to pointlessly rule out nested arrays, complex types, vectors, C structs, and so on.  I think the predicate you probably want here is isTriviallyCopyableType.
> Is there a good reason to use an element-count heuristic instead of a total-size heuristic here?

Yes, the code below generates per-element initialization only for explicitly specified initializers. The rest, if any, is initialized with a filler, so it doesn't affect the size of the resulting code much.


Repository:
  rL LLVM

https://reviews.llvm.org/D43181





More information about the cfe-commits mailing list