Commit Graph

32 Commits

Author SHA1 Message Date
Justin Bogner 203f09223b InstrProf: Fix a misuse of the FunctionDecl API when generating coverage
This was calling FD->hasBody(), meaning "Does the function that this
decl refers to have a body?", rather than
FD->doesThisDeclarationHaveABody(), meaning "Is this decl a
non-deleted definition?".

We might want to consider renaming these APIs :/

llvm-svn: 243360
2015-07-28 00:41:51 +00:00
Justin Bogner 3cfb62da14 InstrProf: Fix a typo in the test for r243066
llvm-svn: 243068
2015-07-23 23:34:26 +00:00
Justin Bogner 61bf8cb9af InstrProf: Don't extend coverage regions into the catch keyword
The catch keyword isn't really part of a region, so it's fairly
meaningless to extend into it. This was usually harmless, but it could
crash when catch blocks involved macros in strange ways.

llvm-svn: 243066
2015-07-23 23:24:21 +00:00
Justin Bogner b05a43f59b InstrProf: Pack the coverage mapping structs that we write out
When we read this data we treat it as unaligned and packed, so we
should really be explicit about that when we write it.

llvm-svn: 241218
2015-07-02 00:42:32 +00:00
Justin Bogner e44dd6dbd0 InstrProf: Fix a crash when an implicit def appears in a macro
llvm-svn: 240452
2015-06-23 20:29:09 +00:00
Justin Bogner 055ebc348d InstrProf: Fix coverage mapping when "if" is a macro
We were propagating the coverage map into the body of an if statement,
but not into the condition thereafter. This is fine as long as the two
locations are in the same virtual file, but they won't be when the
"if" part of the statement is from a macro and the condition is not.

llvm-svn: 239803
2015-06-16 06:24:15 +00:00
Justin Bogner 682bfbf35f InstrProf: Only disable coverage in built-in macros, not all system macros
The issue I was trying to solve in r236547 was about built-in macros,
but I disabled coverage in all system macros. This is actually a bit
of overkill, and makes the display of coverage around system macros
degrade unnecessarily. Instead, limit this to builtins specifically.

llvm-svn: 237397
2015-05-14 22:14:10 +00:00
Justin Bogner 6d721fa28c InstrProf: Don't start or end coverage regions inside of system macros
It doesn't make much sense to try to show coverage inside system
macros, and source locations in builtins confuses the coverage
mapping. Just avoid doing this.

Fixes an assert that fired when a __block storage specifier starts a
region.

llvm-svn: 236547
2015-05-05 21:46:14 +00:00
Justin Bogner 96ae73f724 InstrProf: Fix a coverage crash where a macro begins in an unreachable block
llvm-svn: 236335
2015-05-01 19:23:34 +00:00
Justin Bogner 1587432d1f InstrProf: Make sure coverage propagates out of foreach loops correctly
llvm-svn: 236264
2015-04-30 21:31:02 +00:00
Justin Bogner f959febf7a InstrProf: Mark code regions after throw expressions as unreachable
We weren't setting regions as being unreachable after C++ throw
expressions, leading to incorrect count propagations.

llvm-svn: 235967
2015-04-28 06:31:55 +00:00
Justin Bogner e3654ce7ab InstrProf: Fix coverage maps for conditional operators
This fixes a crash when we're emitting coverage and a macro appears
between two binary conditional operators, ie, "foo ?: MACRO ?: bar",
and fixes the interaction of macros and conditional operators in
general.

llvm-svn: 235793
2015-04-24 23:37:57 +00:00
Justin Bogner 60d852ba5b InstrProf: Fix a shadowing error that would break length of profile names
We try to use the member variable "FuncName" here, but we've also used
that name as a parameter. This ends with us getting the length of the
function name wrong when we generate the coverage data.

llvm-svn: 235565
2015-04-23 00:31:16 +00:00
Justin Bogner f14b207882 InstrProf: Handle whitespace and comments at the ends of macros
When we try to find the end loc for a token, we have to re-lex the
token. This was running into a problem when we'd store the end loc of
a macro's coverage region, since we wouldn't actually be at the
beginning of a token when we tried to re-lex it, leading us to do
silly things (and eventually assert) when whitespace or comments
followed.

This pushes our use of getPreciseTokenLocEnd earlier, so that we won't
call it when it doesn't make sense to. It also removes an unnecessary
adjustment by 1 that was working around this problem in some cases.

llvm-svn: 233169
2015-03-25 04:13:49 +00:00
David Blaikie bdf40a62a7 Test case updates for explicit type parameter to the gep operator
llvm-svn: 232187
2015-03-13 18:21:46 +00:00
Justin Bogner c109102ecb InstrProf: Make sure counts in lambdas don't escape to the parent scope
When generating coverage maps, we were traversing the body as if it
were part of the parent function, but this doesn't make sense since
we're currently counting lambdas as separate functions.

llvm-svn: 230304
2015-02-24 04:13:56 +00:00
Justin Bogner 91f2e3c9c2 InstrProf: Always emit a coverage region for the condition of an if
When tools like llvm-cov show regions, it's much easier to understand
what's happening if the condition of an if shows a counter as well as
the body.

llvm-svn: 229813
2015-02-19 03:10:30 +00:00
Justin Bogner bf42cfd75f InstrProf: Rewrite most of coverage mapping generation in a simpler way
The coverage mapping generation code previously generated a large
number of redundant coverage regions and then tried to merge similar
ones back together. This then relied on some awkward heuristics to
prevent combining of regions that were importantly different but
happened to have the same count. The end result was inefficient and
hard to follow.

Now, we more carefully create the regions we actually want. This makes
it much easier to create regions at precise locations as well as
making the basic approach quite a bit easier to follow. There's still
a fair bit of complexity here dealing with included code and macro
expansions, but that's pretty hard to avoid without significantly
reducing the quality of data we provide.

I had to modify quite a few tests where the source ranges became more
precise or the old ranges seemed to be wrong anyways, and I've added
quite a few new tests since a large number of constructs didn't seem
to be tested before.

llvm-svn: 229748
2015-02-18 21:24:51 +00:00
Justin Bogner 2368c82de0 InstrProf: Add a test for PR22531
This is a test for the llvm change in r228793. We need to make sure
that names referred to by coverage end up in the right section, or the
coverage tools won't work.

llvm-svn: 228794
2015-02-11 02:53:03 +00:00
Justin Bogner 4da909b2b2 InstrProf: Remove CoverageMapping::HasCodeBefore, it isn't used
llvm-svn: 228035
2015-02-03 21:35:49 +00:00
Justin Bogner 00270df517 InstrProf: Avoid creating profile names for symbols in system headers
We don't emit any coverage mapping for uncovered functions that come
from system headers, but we were creating a GlobalVariable with each
of their names. This is wasteful since the linker will need to dead
strip the unused symbols, and it can lead to issues when merging
coverage with others TUs that do have coverage for those functions.

llvm-svn: 226764
2015-01-22 02:17:23 +00:00
Justin Bogner 94d384e423 InstrProf: Don't emit coverage for uninstantiated templates
We include unused functions and methods in -fcoverage-mapping so that
we can differentiate between uninstrumented and unused. This can cause
problems for uninstantiated templates though, since they may involve
an incomplete type that can't be mangled. This shows up in things like
libc++'s <unordered_map> and makes coverage unusable.

Avoid the issue by skipping uninstantiated methods of a templated
class.

llvm-svn: 222204
2014-11-18 00:34:46 +00:00
Justin Bogner f59329b083 InstrProf: Avoid repeated linear searches in a hot path
When generating coverage regions, we were doing a linear search
through the existing regions in order to try to merge related ones.
Most of the time this would find what it was looking for in a small
number of steps and it wasn't a big deal, but in cases with many
regions and few mergeable ones this leads to an absurd compile time
regression.

This changes the coverage mapping logic to do a single sort and then
merge as we go, which is a bit simpler and about 100 times faster.
I've also added FIXMEs on a couple of behaviours that seem a little
suspect, while keeping them behaving as they were - I'll look into
these soon.

The test changes here are mostly tedious reorganization, because the
ordering of regions we output has become slightly (but not completely)
more consistent from the almost completely arbitrary ordering we got
before.

llvm-svn: 218738
2014-10-01 03:33:52 +00:00
Alex Lorenz 1d45c5bc26 Coverage Mapping: store function's hash in coverage function records.
The profile data format was recently updated and the new indexing api
requires the code coverage tool to know the function's hash as well
as the function's name to get the execution counts for a function.

Differential Revision: http://reviews.llvm.org/D4995

llvm-svn: 216208
2014-08-21 19:25:27 +00:00
Alex Lorenz e3b04a9f3b Test: CoverageMapping: use "RUN: FileCheck" command instead of "RUN: cat | Filecheck".
Change the lit RUN commands for 3 tests to use the following pattern
"FileCheck -input-file ..." instead of "cat ... | FileCheck ..." as
suggested by Justin Bogner.

llvm-svn: 216085
2014-08-20 17:29:47 +00:00
Alex Lorenz fdd769e847 Coverage mapping: fix mapping for objective-c for statement
llvm-svn: 216082
2014-08-20 17:11:53 +00:00
Alex Lorenz 01a0d062aa Coverage mapping: fix mapping for objective-c message expression
llvm-svn: 216081
2014-08-20 17:10:56 +00:00
Alex Lorenz b5f3a844a7 Test: Coverage Mapping: add missing RUN commands
Add the llvm-lit RUN commands for the two coverage mapping tests
that filecheck a temporary file.

llvm-svn: 216020
2014-08-19 20:51:54 +00:00
Alex Lorenz 34ac9b5e25 Add tests for coverage mapping generation.
This patch adds the tests for the coverage mapping generation. 
Most of the tests check the mapping regions produced by 
the generator, and one checks the llvm IR.

Differential Revision: http://reviews.llvm.org/D4847

llvm-svn: 215995
2014-08-19 17:32:30 +00:00
Justin Bogner a0101074fd Revert "Add tests for coverage mapping generation."
I reverted one of the added tests from r215261 in r215274, since it
was failing on quite a few bots. It looks like this wasn't sufficient,
as we're still getting failures on windows, like the following:

    http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/5378

I'm reverting this entire commit so the bots aren't blocked on these
failures.

This reverts commit r215261.

llvm-svn: 215278
2014-08-09 03:55:09 +00:00
Justin Bogner 6f147a0966 Revert a failing test from r215261
The (new) CoverageMapping/macroparams.c test is failing on a number of
buildbots. Reverting it until Alex can investigate and fix the test.

llvm-svn: 215274
2014-08-09 01:40:59 +00:00
Alex Lorenz c4ea74a719 Add tests for coverage mapping generation.
This patch adds the tests for the coverage mapping generation. 
Most of the tests check the mapping regions produced by 
the generator, and one checks the llvm IR.

Differential Revision: http://reviews.llvm.org/D4793

llvm-svn: 215261
2014-08-08 23:49:58 +00:00