1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00
Commit Graph

286 Commits

Author SHA1 Message Date
Vedant Kumar
59fa2fd04c [llvm-cov] Don't render empty region marker lines
This fixes an issue where llvm-cov prints an empty line, thinking it
needs to display region markers, when it actually doesn't.

llvm-svn: 317762
2017-11-09 02:33:44 +00:00
Vedant Kumar
8efae3e054 [Coverage] Use the wrapped segment when a line has entry segments
We've worked around bugs in the frontend by ignoring the count from
wrapped segments when a line has at least one region entry segment.
Those frontend bugs are now fixed, so it's time to regenerate the
checked-in covmapping files and remove the workaround.

llvm-svn: 317761
2017-11-09 02:33:43 +00:00
David Blaikie
2b916d7011 GCOV: Move GCOV from IR & Support into ProfileData to fix layering
This class was split between libIR and libSupport, which breaks under
modular code generation. Move it into the one library that uses it,
ProfileData, to resolve this issue.

llvm-svn: 317366
2017-11-03 20:57:10 +00:00
Vedant Kumar
94fdbe848b [llvm-cov] Use a stable sort on sub-views
We need to use a stable sort on instantiation and expansion sub-views to
produce consistent output. Fortunately, we've gotten lucky and the tests
have checks for the stable order.

This is needed to unblock D39245. Once that lands, we'll have better
test coverage for sort non-determinism.

llvm-svn: 316490
2017-10-24 20:03:37 +00:00
Vedant Kumar
f1c5f8681a [llvm-cov] Move LineCoverageIterator to libCoverage. NFC.
LineCoverageIterator makes it easy for clients of coverage data to
determine line execution counts for a file or function. The coverage
iteration logic is tricky enough that it really pays not to have
multiple copies of it. Hopefully having just one implementation in LLVM
will make the iteration logic easier to test, reuse, and update.

This commit is NFC but I've added a unit test to go along with it just
because it's easy to do now.

llvm-svn: 316141
2017-10-18 23:58:28 +00:00
Vedant Kumar
bab56aedc6 [llvm-cov] Use the coverage namespace. NFC.
This is a simple code cleanup. It will facilitate moving
LineCoverageIterator to libCoverage.

llvm-svn: 316140
2017-10-18 23:58:27 +00:00
Vedant Kumar
6314aa41e9 [llvm-cov] Suppress sub-line highlights in simple cases
llvm-cov tends to highlight too many regions because its policy is to
highlight all region entry segments. This can look confusing to users:
not all region entry segments are interesting and deserve highlighting.
Emitting these highlights only when the region count differs from the
line count is a more user-friendly policy.

llvm-svn: 316109
2017-10-18 18:52:29 +00:00
Vedant Kumar
6c2710f166 [llvm-cov] Pass LineCoverageStats in SourceCoverageView. NFC.
Instead of copying around the wrapped segment and the list of line
segments, just pass a reference to a LineCoverageStats object. This
simplifies the interface. It also makes an upcoming change to suppress
distracting highlights possible.

llvm-svn: 316108
2017-10-18 18:52:28 +00:00
Vedant Kumar
ff20a555f6 [llvm-cov] Highlight gaps in consecutive uncovered regions
llvm-cov typically doesn't highlight gap segments, but it should if the
gap occurs after an uncovered region in order to preserve continuity.

llvm-svn: 316107
2017-10-18 18:52:27 +00:00
Vedant Kumar
200728ffcb [llvm-cov] Add one correction to r315960 (PR34962)
In r315960, I accidentally assumed that the first line segment is
guaranteed to be the non-gap region entry segment (given that one is
present). It can actually be any segment on the line, and the test I
checked in demonstrates that.

llvm-svn: 315963
2017-10-17 01:34:41 +00:00
Vedant Kumar
10feee95ac [llvm-cov] Remove workaround in line execution count calculation (PR34962)
Gap areas make it possible to correctly determine when to use counts
from deferred regions. Before gap areas were introduced, llvm-cov needed
to use a heuristic to do this: it ignored counts from segments that
start, but do not end, on a line. This heuristic breaks down on a simple
example (see PR34962).

This patch removes the heuristic and picks counts from any region entry
segment which isn't a gap area.

llvm-svn: 315960
2017-10-16 23:47:10 +00:00
Vedant Kumar
e010115612 [llvm-cov] Factor out logic to iterate over line coverage stats (NFC)
There were two copies of the logic needed to construct a line stats
object for each line in a range: this patch brings it down to one. In
the future, this will make it easier for IDE clients to display coverage
in-line in source editors. To do that, we just need to move the new
LineCoverageIterator class to libCoverage.

llvm-svn: 315789
2017-10-14 02:27:29 +00:00
Max Moroz
80a27c3a17 [llvm-cov] Generate "report" for given source paths if sources are specified.
Summary:
Documentation says that user can specify sources for both "show" and
"report" commands. "Show" command respects specified sources, but "report" does
not. It is useful to have both "show" and "report" generated for specified
sources. Also added tests to for both commands with sources specified.

Reviewers: vsk, kcc

Reviewed By: vsk

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

llvm-svn: 315685
2017-10-13 14:44:51 +00:00
Sean Eveson
69a379ddcd [llvm-cov] Fix showing title when filtering and not outputting to a directory
Differential Revision: https://reviews.llvm.org/D38507

llvm-svn: 314885
2017-10-04 08:54:37 +00:00
Sean Eveson
39aefb7654 [llvm-cov] Hide files with no coverage from the index when filtering by name
Differential Revision: https://reviews.llvm.org/D38457

llvm-svn: 314782
2017-10-03 11:05:28 +00:00
Sean Eveson
e5dd14d47e [llvm-cov] Create directory structure when filtering using -name*= options
Before this change using any of the -name*= command line options with an output
directory would result in a single file (functions.txt/functions.html)
containing the coverage for those specific functions. Now you get the same
directory structure as when not using any -name*= options.

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

llvm-svn: 314396
2017-09-28 10:07:30 +00:00
Sean Eveson
79635bcbf9 Revert "[llvm-cov] Create directory structure when filtering using -name*= options"
Test failures.

llvm-svn: 314314
2017-09-27 16:20:07 +00:00
Sean Eveson
bdf63e8c8b [llvm-cov] Create directory structure when filtering using -name*= options
Before this change using any of the -name*= command line options with an output
directory would result in a single file (functions.txt/functions.html)
containing the coverage for those specific functions. Now you get the same
directory structure as when not using any -name*= options.

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

llvm-svn: 314310
2017-09-27 15:37:40 +00:00
Sean Eveson
1b0cafe05f [llvm-cov] Improve const-correctness of filters. NFC.
llvm-svn: 314281
2017-09-27 08:32:36 +00:00
Vedant Kumar
d0c6992660 [llvm-cov] Warn if -show-functions is used without query files
llvm-cov's report mode does not print any output when -show-functions is
specified and no source files are specified. This can be surprising, so
the tool should at least print out an error message when this happens.

rdar://problem/34636859

llvm-svn: 314175
2017-09-25 23:10:03 +00:00
Vlad Tsyrklevich
0b4abdf3cc Add section headers to SpecialCaseLists
Summary:
Sanitizer blacklist entries currently apply to all sanitizers--there
is no way to specify that an entry should only apply to a specific
sanitizer. This is important for Control Flow Integrity since there are
several different CFI modes that can be enabled at once. For maximum
security, CFI blacklist entries should be scoped to only the specific
CFI mode(s) that entry applies to.

Adding section headers to SpecialCaseLists allows users to specify more
information about list entries, like sanitizer names or other metadata,
like so:

  [section1]
  fun:*fun1*
  [section2|section3]
  fun:*fun23*

The section headers are regular expressions. For backwards compatbility,
blacklist entries entered before a section header are put into the '[*]'
section so that blacklists without sections retain the same behavior.

SpecialCaseList has been modified to also accept a section name when
matching against the blacklist. It has also been modified so the
follow-up change to clang can define a derived class that allows
matching sections by SectionMask instead of by string.

Reviewers: pcc, kcc, eugenis, vsk

Reviewed By: eugenis, vsk

Subscribers: vitalybuka, llvm-commits

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

llvm-svn: 314170
2017-09-25 22:11:11 +00:00
Reid Kleckner
e0df0bbd27 [Support] Rename tool_output_file to ToolOutputFile, NFC
This class isn't similar to anything from the STL, so it shouldn't use
the STL naming conventions.

llvm-svn: 314050
2017-09-23 01:03:17 +00:00
Vedant Kumar
0284aa24eb [llvm-cov] Improve error messaging for function mismatches
Passing "-dump" to llvm-cov will now print more detailed information
about function hash and counter mismatches. This should make it easier
to debug *.profdata files which contain incorrect records, and to debug
other scenarios where coverage goes missing due to mismatch issues.

llvm-svn: 313853
2017-09-21 01:11:30 +00:00
Vedant Kumar
019979919f [llvm-cov] Make report metrics agree with line exec counts, fixes PR34615
Use the same logic as the line-oriented coverage view to determine the
number of covered lines in a function.

Fixes llvm.org/PR34615.

llvm-svn: 313604
2017-09-19 02:00:12 +00:00
Vedant Kumar
65c67f5133 [Coverage] Use gap regions to select better line exec counts
After clang started emitting deferred regions (r312818), llvm-cov has
had a hard time picking reasonable line execuction counts. There have
been one or two generic improvements in this area (e.g r310012), but
line counts can still report coverage for whitespace instead of code
(llvm.org/PR34612).

To fix the problem:

 * Introduce a new region kind so that frontends can explicitly label
   gap areas.

   This is done by changing the encoding of the columnEnd field of
   MappingRegion. This doesn't substantially increase binary size, and
   makes it easy to maintain backwards-compatibility.

 * Don't set the line count to a count from a gap area, unless the count
   comes from a wrapped segment.

 * Don't highlight gap areas as uncovered.

Fixes llvm.org/PR34612.

llvm-svn: 313597
2017-09-18 23:37:28 +00:00
Vedant Kumar
901e6b85af [llvm-cov] Simplify code to find the first uncovered segment. NFC.
Now that that segment builder is guaranteed to produce segments in
sorted order, we don't need a linear scan to get the right result.

llvm-svn: 313595
2017-09-18 23:37:27 +00:00
Vedant Kumar
9bf41686e1 [llvm-cov] Fix a bot failure due to r313417
There's a type mismatch issue with the arguments to a call to std::min
introduced in r313417.

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/11174

llvm-svn: 313422
2017-09-15 23:14:22 +00:00
Vedant Kumar
b939a54424 [llvm-cov] Avoid over-counting covered lines and regions
* Fix an unsigned integer overflow in the logic that computes the
  number of uncovered lines in a function.

* When aggregating region and line coverage summaries, take into account
  that different instantiations may have a different number of regions.

The new test case provides test coverage for both bugs. I also verified
this change by preparing a coverage report for a stage2 build of llc --
the new assertions should detect any outstanding over-counting bugs.

Fixes PR34613.

llvm-svn: 313417
2017-09-15 23:00:02 +00:00
Vedant Kumar
a4cb081af1 [llvm-cov] Make some summary info fields private. NFC.
There's a bug in the way the line and region summary objects are merged.
It would have been less likely to occur if those objects kept some data
private.

llvm-svn: 313416
2017-09-15 23:00:01 +00:00
Vedant Kumar
9a91c24748 [llvm-cov] Remove a redundant field. NFC.
The "NotCovered" fields in the region and line summary structs are
redundant. We should remove them to make the code clearer.

As a follow-up, the "NotCovered" entries should be removed from the
reports as well.

llvm-svn: 313415
2017-09-15 23:00:00 +00:00
Alexander Kornienko
12bc887fe5 Convenience/safety fix for llvm::sys::Execute(And|No)Wait
Summary:
Change the type of the Redirects parameter of llvm::sys::ExecuteAndWait,
ExecuteNoWait and other APIs that wrap them from `const StringRef **` to
`ArrayRef<Optional<StringRef>>`, which is safer and simplifies the use of these
APIs (no more local StringRef variables just to get a pointer to).

Corresponding clang changes will be posted as a separate patch.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: vsk, llvm-commits

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

llvm-svn: 313155
2017-09-13 17:03:37 +00:00
Eli Friedman
c6624fa39c [llvm-cov] Allow hiding instantiation/region coverage from summary tables
Region coverage is difficult to explain without going deep into how
coverage is implemented. Instantiation coverage is easier to explain,
but probably not useful in most cases (templates don't exist in C, and
most C++ code contains relatively few templates).

This patch adds the options "-show-region-summary" and
"-show-instantiation-summary" to allow hiding those columns.
"-show-instantiation-summary" is turned off by default.

llvm-svn: 312969
2017-09-11 22:56:20 +00:00
Vedant Kumar
37bb41602e [llvm-cov] Don't attach exec counts to lines which start a skipped region
These lines by definition don't have an execution count.

This is the final part of the fix for:
https://bugs.llvm.org/show_bug.cgi?id=34166

llvm-svn: 312955
2017-09-11 21:31:32 +00:00
Vedant Kumar
0c4688ed62 [llvm-cov] Fix a lifetime issue
This fixes an issue where a std::string was moved to a constructor
which accepted a StringRef.

llvm-svn: 312816
2017-09-08 18:44:49 +00:00
Vedant Kumar
3431ecb291 [llvm-cov] Unify region marker placement between text/html modes
Make sure that the text and html emitters always emit the same set of
region markers, and avoid emitting redundant markers for line segments
which don't end on the line they start on.

This is related to D35925, and depends on D36014

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

llvm-svn: 312813
2017-09-08 18:44:46 +00:00
Sean Eveson
42bd8958bb [llvm-cov] Read in function names for filtering from a text file.
Summary: Add a -name-whitelist option, which behaves in the same way as -name, but it reads in multiple function names from the given input file(s).

Reviewers: vsk

Reviewed By: vsk

Subscribers: llvm-commits

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

llvm-svn: 312227
2017-08-31 09:11:31 +00:00
Sean Eveson
e2fe4189b2 [llvm-cov] Add an option which maps the location of source directories on another machine to your local copies
Summary:
This patch adds the -path-equivalence option (example: llvm-cov show -path-equivalence=/origin/path,/local/path) which maps the source code path from one machine to another when using `llvm-cov show`. This is similar to the -filename-equivalence option, but doesn't require you to specify all the source files on the command line.

This allows you to generate the coverage data on one machine (e.g. in a CI system), and then use llvm-cov on another machine where you have the same code base on a different path.

Reviewers: vsk

Reviewed By: vsk

Subscribers: llvm-commits

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

llvm-svn: 310827
2017-08-14 10:20:12 +00:00
Eli Friedman
c66894b149 [llvm-cov] Rearrange entries in report index.
Files which don't contain any functions are likely useless; don't
include them in the main table. Put the links at the bottom of the
page, in case someone wants to figure out coverage for code inside
a macro.

Not sure if this is the best solution, but it seems like an
improvement.

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

llvm-svn: 310518
2017-08-09 20:43:31 +00:00
Vedant Kumar
d0e8e6729c [llvm-cov] Ignore unclosed line segments when setting line counts
This patch makes a slight change to the way llvm-cov determines line
execution counts. If there are multiple line segments on a line, the
line count is the max count among the regions which start *and* end on
the line. This avoids an issue posed by deferred regions which start on
the same line as a terminated region, e.g:

  if (false)
    return; //< The line count should be 0, even though a new region
            //< starts at the semi-colon.
  foo();

Another change is that counts from line segments which don't correspond
to region entries are considered. This enables the first change, and
corrects an outstanding issue (see the showLineExecutionCounts.cpp test
change).

This is related to D35925.

Testing: check-profile, llvm-cov lit tests

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

llvm-svn: 310012
2017-08-04 00:36:24 +00:00
Vedant Kumar
f4f1292ac7 [llvm-cov] NFC: make_unique-ify two allocations
llvm-svn: 310011
2017-08-04 00:36:24 +00:00
Vedant Kumar
19b73c8e94 [Coverage] Add an API to retrive all instantiations of a function (NFC)
The CoverageMapping::getInstantiations() API retrieved all function
records corresponding to functions with more than one instantiation (e.g
template functions with multiple specializations). However, there was no
simple way to determine *which* function a given record was an
instantiation of. This was an oversight, since it's useful to aggregate
coverage information over all instantiations of a function.

llvm-cov works around this by building a mapping of source locations to
instantiation sets, but this duplicates logic that libCoverage already
has (see FunctionInstantiationSetCollector).

This change adds a new API, CoverageMapping::getInstantiationGroups(),
which returns a list of InstantiationGroups. A group contains records
for each instantiation of some particular function, and also provides
utilities to get the total execution count within the group, the source
location of the common definition, etc.

This lets removes some hacky logic in llvm-cov by reusing
FunctionInstantiationSetCollector and makes the CoverageMapping API
friendlier for other clients.

llvm-svn: 309904
2017-08-02 23:35:25 +00:00
Vedant Kumar
869b6676ef [llvm-cov] Respect the value of the -show-instantiations option
Make `-show-instantiations=false` actually skip displaying instantiation
sub-views, instead of simply ignoring the option.

llvm-svn: 309903
2017-08-02 23:35:24 +00:00
Vedant Kumar
95aaeaf3f0 [llvm-cov] Allow specifying distinct architectures for each loaded binary
The coverage tool needs to know which slice to look at when it's handed
a universal binary. Some projects need to look at aggregate coverage
reports for a variety of slices in different binaries: this patch adds
support for these kinds of projects to llvm-cov.

rdar://problem/33579007

llvm-svn: 309747
2017-08-01 21:23:26 +00:00
Vedant Kumar
5521d918cc [llvm-cov] Add a cl::opt to control the number of threads
When an output directory is specified, llvm-cov spawns some threads to
speed up the process of writing out file reports. Add an option which
allows users to control how many threads llvm-cov uses.

A CommandGuide.rst update + test is included.

llvm-svn: 307609
2017-07-11 01:23:29 +00:00
Vedant Kumar
f7f1e6f3b0 [ProfileData] Unify getInstrProf*SectionName helpers
This is a version of D32090 that unifies all of the
`getInstrProf*SectionName` helper functions. (Note: the build failures
which D32090 would have addressed were fixed with r300352.)

We should unify these helper functions because they are hard to use in
their current form. E.g we recently introduced more helpers to fix
section naming for COFF files. This scheme doesn't totally succeed at
hiding low-level details about section naming, so we should switch to an
API that is easier to maintain.

This is not an NFC commit because it fixes llvm-cov's testing support
for COFF files (this falls out of the API change naturally). This is an
area where we lack tests -- I will see about adding one as a follow up.

Testing: check-clang, check-profile, check-llvm.

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

llvm-svn: 300381
2017-04-15 00:09:57 +00:00
Xinliang David Li
96faeb6322 [Profile] PE binary coverage bug fix
PR/32584

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

llvm-svn: 300277
2017-04-13 23:37:12 +00:00
Zachary Turner
84ce56f415 Use the new member accessors of llvm::enumerate.
The value_type is no longer a struct, it's a class whose
members you have to access via a method.

llvm-svn: 297635
2017-03-13 16:32:08 +00:00
Vedant Kumar
32c8d92826 [llvm-cov] Error-out when an unsupported format is used (PR32087)
llvm-svn: 296487
2017-02-28 16:57:28 +00:00
Vedant Kumar
340a374fe7 [llvm-cov] Strip redundant path components from filenames (fix PR31982)
Instead of stripping the longest common prefix off of the filenames in a
report, strip out the longest chain of redundant path components. This
fixes the case in PR31982, where there are two files with the same
prefix, and stripping out the LCP makes things less intelligible.

llvm-svn: 296029
2017-02-23 22:20:32 +00:00
Igor Kudrin
94f3f93b77 [llvm-cov] Respect Windows line endings when parsing demangled symbols.
Differential Revision: https://reviews.llvm.org/D30096

llvm-svn: 295605
2017-02-19 14:26:52 +00:00