[PATCH] D42612: [GlobalOpt] Improve common case efficiency of static global initializer evaluation

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 19:12:24 PST 2018


aemerson created this revision.
aemerson added a reviewer: Gerolf.

For very, very large global initializers which can be statically evaluated, the existing code would create vectors of temporary Constants, modifying them in place,  before committing the resulting Constant aggregate to the global's initializer value. This had effectively O(n^2) complexity in the size of the global initializer and would cause memory and non-termination issues compiling some workloads.

This change performs the static initializer evaluation and creation in batches, once for each global in the evaluated IR memory. The existing code is maintained as a last resort when the initializers are more complex than simple values in a large aggregate. This should theoretically by NFC, no test as the example case is massive. The existing test cases pass with this, as well as the llvm test suite.


Repository:
  rL LLVM

https://reviews.llvm.org/D42612

Files:
  lib/Transforms/IPO/GlobalOpt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42612.131677.patch
Type: text/x-patch
Size: 3979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180127/e1d5f711/attachment.bin>


More information about the llvm-commits mailing list