[Coverage] Refactor SIL generation for profiling

This patch moves the ownership of profiling state from SILGenProfiling
to SILFunction, where it always belonged. Similarly, it moves ownership
of the profile reader from SILGenModule to SILModule.

The refactor sets us up to fix a few outstanding code coverage bugs and
does away with sad hacks like ProfilerRAII. It also allows us to locally
guarantee that a profile counter increment actually corresponds to the
SILFunction at hand.

That local guarantee causes a bugfix to accidentally fall out of this
refactor: we now set up the profiling state for delayed functions
correctly. Previously, we would set up a ProfilerRAII for the delayed
function, but its counter increment would never be emitted :(. This fix
constitutes the only functional change in this patch -- the rest is NFC.

As a follow-up, I plan on removing some dead code in the profiling
logic and fixing a few naming inconsistencies. I've left that for later
to keep this patch simple.
This commit is contained in:
Vedant Kumar
2017-12-21 10:51:56 -08:00
parent 461c764734
commit aba9d53736
21 changed files with 336 additions and 236 deletions

View File

@@ -44,7 +44,7 @@ SILCoverageMap::create(SILModule &M, StringRef Filename, StringRef Name,
}
SILCoverageMap::SILCoverageMap(uint64_t Hash, bool External)
: External(External), Hash(Hash) {}
: External(External), Hash(Hash), HasSymtabEntry(false) {}
SILCoverageMap::~SILCoverageMap() {}