[GCOV] Emit the writeout function as nested loops of global data.
authorChandler Carruth <chandlerc@gmail.com>
Wed, 2 May 2018 22:24:39 +0000 (22:24 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 2 May 2018 22:24:39 +0000 (22:24 +0000)
commit71c3a3fac521be022d493cd78e9ec00a7a42dae5
treefb7b2c2216e24f1eb87c3d03282b9ca37cdf9d49
parentfbe748ae868feddf8dd7169ce89206bc29bbb11c
[GCOV] Emit the writeout function as nested loops of global data.

Summary:
Prior to this change, LLVM would in some cases emit *massive* writeout
functions with many 10s of 1000s of function calls in straight-line
code. This is a very wasteful way to represent what are fundamentally
loops and creates a number of scalability issues. Among other things,
register allocating these calls is extremely expensive. While D46127 makes this
less severe, we'll still run into scaling issues with this eventually. If not
in the compile time, just from the code size.

Now the pass builds up global data structures modeling the inputs to
these functions, and simply loops over the data structures calling the
relevant functions with those values. This ensures that the code size is
a fixed and only data size grows with larger amounts of coverage data.

A trivial change to IRBuilder is included to make it easier to build
the constants that make up the global data.

Reviewers: wmi, echristo

Subscribers: sanjoy, mcrosier, llvm-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D46357

llvm-svn: 331407
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/test/Transforms/GCOVProfiling/function-numbering.ll