[PATCH] D11200: Improve merging of stores from static constructors in GlobalOpt

Anthony Pesch inolen at gmail.com
Tue Jul 14 14:48:47 PDT 2015


inolen created this revision.
inolen added a reviewer: chandlerc.
inolen added a subscriber: llvm-commits.
inolen set the repository for this revision to rL LLVM.

While working on a project I wound up generating a fairly large lookup table (10k entries) of callbacks inside of a static constructor. Clang was taking upwards of ~10 minutes to compile the lookup table. I generated a smaller test case (http://www.inolen.com/static_initializer_test.ll) that, after running with -ftime-report, pointed fingers at GlobalOpt and MemCpyOptimizer.

Running globalopt took around ~9 minutes. The slowdown came from how GlobalOpt merged stores from static constructors individually into the global initializer in EvaluateStaticConstructor. For each store it discovered and wanted to commit, it would copy the existing global initializer and then merge in the individual store. I changed this so that stores are now grouped by global, and sorted from most significant to least significant by their GEP indexes (e.g. a store to GEP 0, 0 comes before GEP 0, 0, 1). With this representation, the existing initializer can be copied and all new stores merged into it in a single pass.

With this patch and http://reviews.llvm.org/D11198, the lookup table that was taking ~10 minutes to compile now compiles in around 5 seconds. I've ran 'make check' and the test-suite, which all passed.

I'm not really sure who to tag as a reviewer, Lang mentioned that Chandler may be appropriate.
 

Repository:
  rL LLVM

http://reviews.llvm.org/D11200

Files:
  lib/Transforms/IPO/GlobalOpt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11200.29714.patch
Type: text/x-patch
Size: 10983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150714/6fd006a4/attachment.bin>


More information about the llvm-commits mailing list