Start visiting LazyInitializerExpr for profiling,
such that we emit a profile counter when
initializing the initial value for the first time.
rdar://43393937
Stop profiling the deallocating deinitializer
function for non-ObjC classes, and instead profile
the destructor, which is where we emit the user's
code written in a `deinit`.
rdar://54443107
Assign separate SILProfiler instances to stored property initializers
and constructors.
Starting with rdar://39460313, coverage reporting for these constructs
was bundled up into a single SILProfiler uniqued by the NominalTypeDecl.
There are two problems with doing this.
First, the shared SILProfiler is given a fake name that can't be
demangled. That breaks Xcode's reports. Second, the relationship
between SILProfiler and SILFunction is supposed to be 1:1. Having a
shared SILProfiler muddies things a bit and requires extra bookkeeping.
rdar://47467864
ASTWalker visits a lazy_initializer_expr once within its associated
var_decl (by way of the parent nominal type). However, SILGen visits the
lazy_initializer_expr while inside of the var_decl's getter. The result
is that there is no coverage mapping information for the contents of the
lazy init within the getter's SILProfiler.
Fixing this will require reworking how profile counters are assigned to
be more in line with what SILGen needs.
As a stop-gap, this patch prevents SILGen from asserting that coverage
mappings are complete with a defensive check which prevents a crash seen
in SR-8429.
rdar://42792053
* Group tests for profiling instrumentation together, NFC
This will make it easier to test changes to the code coverage logic.
There are a handful of tests which relate to profiling which I have not
moved. These include tests for the driver and for the SIL optimizer. It
makes more sense to keep those tests where they are.
* Rename a test file, NFC
This file tests code coverage of primary files, so I've changed the name
of the file to reflect that.
* Simplify the check lines in a test, NFC
This file tests code coverage of closures. It had several check lines
which obscured the meaning of the test, and its check lines were in a
strange order.
Remove the extra checks and disable -emit-sorted-sil.