aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/CoverageMappingTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-11-30[Coverage] Use the most-recent completed region count (PR35437)Vedant Kumar1-0/+26
This is a fix for the coverage segment builder. If multiple regions must be popped off the active stack at once, and more than one of them end at the same location, emit a segment using the count from the most-recent completed region. Fixes PR35437, rdar://35760630 Testing: invoked llvm-cov on a stage2 build of clang, additional unit tests, check-profile llvm-svn: 319391
2017-11-09[Coverage] Use the wrapped segment when a line has entry segmentsVedant Kumar1-1/+2
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-10-19[Coverage] Simplify r316141. NFC.Vedant Kumar1-41/+6
llvm-svn: 316147
2017-10-18[llvm-cov] Move LineCoverageIterator to libCoverage. NFC.Vedant Kumar1-0/+57
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-09-09CoverageMappingTest.cpp: Suppress warnings. [-Wdocumentation]NAKAMURA Takumi1-6/+6
llvm-svn: 312861
2017-09-08[Coverage] Build sorted and unique segmentsVedant Kumar1-3/+238
A coverage segment contains a starting line and column, an execution count, and some other metadata. Clients of the coverage library use segments to prepare line-oriented reports. Users of the coverage library depend on segments being unique and sorted in source order. Currently this is not guaranteed (this is why the clang change which introduced deferred regions was reverted). This commit documents the "unique and sorted" condition and asserts that it holds. It also fixes the SegmentBuilder so that it produces correct output in some edge cases. Testing: I've added unit tests for some edge cases. I've also checked that the new SegmentBuilder implementation is fully covered. Apart from running check-profile and the llvm-cov tests, I've successfully used a stage1 llvm-cov to prepare a coverage report for an instrumented clang binary. Differential Revision: https://reviews.llvm.org/D36813 llvm-svn: 312817
2017-08-02[Coverage] Add an API to retrive all instantiations of a function (NFC)Vedant Kumar1-3/+4
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-07-10llvm-profdata: Reduce memory usage by using Error callback rather than memberDavid Blaikie1-31/+18
Reduces llvm-profdata memory usage on a large profile from 7.8GB to 5.1GB. The ProfData API now supports reporting all the errors/warnings rather than only the first, though llvm-profdata ignores everything after the first for now to preserve existing behavior. (if there's a desire for other behavior, happy to implement that - but might be as well left for a separate patch) Reviewers: davidxl Differential Revision: https://reviews.llvm.org/D35149 llvm-svn: 307516
2017-07-07ProfData: Fix some unchecked Errors in unit testsDavid Blaikie1-42/+52
The 'NoError' function was meant to be used as the input to ASSERT/EXPECT_TRUE, but it is easy to forget this (it could be annotated with nodiscard to help this) so many sites that look like they're checked are not (& silently discard the failure). Only one site actually has an Error sneaking out this way and I've replaced that one with a FIXME+consumeError. The rest of the code has been modified to use the EXPECT_THAT_ERROR macros Zach introduced a while back. Between the options available this seems OK/good/something to standardize on - though it's difficult to build a matcher that could handle checking for a specific llvm::Error result, so those remain using the custom ErrorEquals (& the nodiscard added to ensure it is not misused as it was previous to this patch). It could still be generalized a bit further (even not as far as a matcher, but at least support multiple kinds of Error, etc) & added to the general Error utility header. llvm-svn: 307440
2017-07-06Simplify InstrProfRecord tests, eliminating named temporaries in favor of ↵David Blaikie1-32/+16
braced init args This will also simplify an API transition and class renaming coming soon. llvm-svn: 307236
2017-06-30Try to appease a buildbot.Vedant Kumar1-1/+2
The failure is: C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\unittests\ProfileData\CoverageMappingTest.cpp(244): error C2668: 'llvm::make_unique': ambiguous call to overloaded function http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/3489/ llvm-svn: 306784
2017-06-30[Coverage] Remove two overloads of CoverageMapping::load. NFC.Vedant Kumar1-8/+9
These overloads are essentially dead, and pose a maintenance cost without adding any benefit. This is coming up now because I'd like to experiment with changing the way we store coverage mapping data, and would rather not have to fix up the old overloads while doing so. Testing: check-{llvm,profile}, build clang. llvm-svn: 306776
2017-06-20[Coverage] PR33517: Check for failure to load func recordsVedant Kumar1-16/+39
With PR33517, it became apparent that symbol table creation can fail when presented with malformed inputs. This patch makes that sort of error detectable, so llvm-cov etc. can fail more gracefully. Specifically, we now check that function records loaded from corrupted coverage mapping data are rejected, e.g when the recorded function name is garbage. Testing: check-{llvm,clang,profile}, some unit test updates. llvm-svn: 305767
2017-06-04Fixed warning: must specify at least one argument for '...' parameter.Galina Kistanova1-1/+1
llvm-svn: 304676
2017-03-11Fix signed/unsigned comparison warningSimon Pilgrim1-1/+1
llvm-svn: 297565
2016-11-20Fix spelling mistakes in Tools/Tests comments. NFC.Simon Pilgrim1-1/+1
Identified by Pedro Giffuni in PR27636. llvm-svn: 287489
2016-10-14[Coverage] Support loading multiple binaries into a CoverageMappingVedant Kumar1-6/+42
Add support for loading multiple coverage readers into a single CoverageMapping instance. This should make it easier to prepare a unified coverage report for multiple binaries. Differential Revision: https://reviews.llvm.org/D25535 llvm-svn: 284251
2016-10-13[unittests] Remove a redundant test fixture (NFC)Vedant Kumar1-30/+19
llvm-svn: 284135
2016-10-12[unittests] Delete even more copy constructors (NFC)Vedant Kumar1-0/+10
llvm-svn: 284069
2016-10-12[unittests] Delete some copy constructors (NFC)Vedant Kumar1-0/+11
llvm-svn: 284066
2016-10-12[unittest] Pass a reference instead of making a copy (NFC)Vedant Kumar1-1/+1
llvm-svn: 284065
2016-07-21Rename StringMap::emplace_second to try_emplace.Benjamin Kramer1-1/+1
Coincidentally this function maps to the C++17 try_emplace. Rename it for consistentcy with C++17 std::map. NFC. llvm-svn: 276276
2016-05-19Retry^3 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-9/+9
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Changes since the initial commit: - Fix error message printing in llvm-profdata. - Check errors in loadTestingFormat() + annotateAllFunctions(). - Defer error handling in InstrProfIterator to InstrProfReader. - Remove the base ProfError class to work around an MSVC ICE. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 270020
2016-05-16Revert "Retry^2 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC""Vedant Kumar1-9/+9
This reverts commit r269694. MSVC says: error C2086: 'char llvm::ProfErrorInfoBase<enum llvm::instrprof_error>::ID' : redefinition llvm-svn: 269700
2016-05-16Retry^2 "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-9/+9
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Changes since the initial commit: - Address undefined-var-template warning. - Fix error message printing in llvm-profdata. - Check errors in loadTestingFormat() + annotateAllFunctions(). - Defer error handling in InstrProfIterator to InstrProfReader. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 269694
2016-05-14Revert "Retry "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC""Chandler Carruth1-9/+9
This reverts commit r269491. It triggers warnings with Clang, breaking builds for -Werror users including several build bots. llvm-svn: 269547
2016-05-13Retry "[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-9/+9
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Changes since the initial commit: - Fix error message printing in llvm-profdata. - Check errors in loadTestingFormat() + annotateAllFunctions(). - Defer error handling in InstrProfIterator to InstrProfReader. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 269491
2016-05-13Revert "(HEAD -> master, origin/master, origin/HEAD) [ProfileData] (llvm) ↵Vedant Kumar1-9/+9
Use Error in InstrProf and Coverage, NFC" This reverts commit r269462. It fails two llvm-profdata tests. llvm-svn: 269466
2016-05-13[ProfileData] (llvm) Use Error in InstrProf and Coverage, NFCVedant Kumar1-9/+9
Transition InstrProf and Coverage over to the stricter Error/Expected interface. Differential Revision: http://reviews.llvm.org/D19901 llvm-svn: 269462
2016-05-12[unittests] Use coveragemap_error in CoverageMappingReaderMock (NFC)Vedant Kumar1-2/+2
llvm-svn: 269324
2016-05-05[Coverage] Combine counts of expansion regions if there are no code regions ↵Igor Kudrin1-0/+25
for the same area. Differential Revision: http://reviews.llvm.org/D18831 llvm-svn: 268620
2016-05-03[ProfileData] Assert NoError in CoverageMappingTestVedant Kumar1-13/+13
Check for success values in the CoverageMappingTest unit test file. This is part of a series of patches to transition ProfileData over to the stricter Error/Expected interface. llvm-svn: 268420
2016-04-29Move coverage related code into a separate library.Easwaran Raman1-3/+3
Differential Revision: http://reviews.llvm.org/D19333 llvm-svn: 268089
2016-04-25[Coverage] Restore the correct count value after processing a nested region ↵Igor Kudrin1-0/+20
in case of combined regions. If several regions cover the same area of code, we have to restore the combined value for that area when return from a nested region. This patch achieves that by combining regions before calling buildSegments. Differential Revision: http://reviews.llvm.org/D18610 llvm-svn: 267390
2016-04-18Reapply "[Coverage] Prevent detection of false instantiations in case of ↵Igor Kudrin1-0/+38
macro expansion." The root of the problem was that findMainViewFileID(File, Function) could return some ID for any given file, even though that file was not the main file for that function. This patch ensures that the result of this function is conformed with the result of findMainViewFileID(Function). This commit reapplies r266436, which was reverted by r266458, with the .covmapping file serialized in v1 format. Differential Revision: http://reviews.llvm.org/D18787 llvm-svn: 266620
2016-04-18[NFC] Header cleanupMehdi Amini1-1/+1
Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
2016-04-15Revert "[Coverage] Prevent detection of false instantiations in case of ↵Igor Kudrin1-38/+0
macro expansion." This reverts commit r266436 as it broke buildbot. llvm-svn: 266458
2016-04-15[Coverage] Prevent detection of false instantiations in case of macro expansion.Igor Kudrin1-0/+38
The root of the problem was that findMainViewFileID(File, Function) could return some ID for any given file, even though that file was not the main file for that function. This patch ensures that the result of this function is conformed with the result of findMainViewFileID(Function). Differential Revision: http://reviews.llvm.org/D18787 llvm-svn: 266436
2016-04-15[Coverage] Add support for making test data for more than one function.Igor Kudrin1-83/+169
Differential Revision: http://reviews.llvm.org/D18758 llvm-svn: 266434
2016-04-14[Coverage] Update testing methods to support more than two filesIgor Kudrin1-11/+58
Differential Revision: http://reviews.llvm.org/D18757 llvm-svn: 266289
2016-03-28[Coverage] Strip <unknown> from PGO names if no filenames are availableVedant Kumar1-4/+6
Patch suggested by David Li! llvm-svn: 264586
2016-03-28[Coverage] Fix the way we load "<unknown>:func" recordsVedant Kumar1-0/+15
When emitting coverage mappings for functions with local linkage and an unknown filename, we use "<unknown>:func" for the PGO function name. The problem is that we don't strip "<unknown>" from the name when loading coverage data, like we do for other file names. Fix that and add a test. llvm-svn: 264559
2016-01-29[Profiling] Add a -sparse mode to llvm-profdata mergeVedant Kumar1-11/+26
Add an option to llvm-profdata merge for writing out sparse indexed profiles. These profiles omit InstrProfRecords for functions which are never executed. Differential Revision: http://reviews.llvm.org/D16727 llvm-svn: 259258
2015-09-29InstrProf: Support for value profiling in the indexed profile formatJustin Bogner1-4/+8
Add support to the indexed instrprof reader and writer for the format that will be used for value profiling. Patch by Betul Buyukkurt, with minor modifications. llvm-svn: 248833
2015-05-13InstrProf: Treat functions with a coverage map but no profile as unreachedJustin Bogner1-0/+15
If we have a coverage mapping but no profile data for a function, calling it mismatched is misleading. This can just as easily be unreachable code that was stripped from the binary. Instead, treat these the same as functions where we have an explicit "zero" coverage map by setting the count to zero for each mapped region. llvm-svn: 237298
2015-05-05InstrProf: Strip filename prefixes from the names we display for coverageJustin Bogner1-0/+14
For consumers of coverage data, any filename prefixes we store in the profile data are just noise. Strip this prefix if it exists. llvm-svn: 236558
2015-02-18InstrProf: Don't combine expansion regions with code regionsJustin Bogner1-0/+37
This was leading to duplicate counts when a code region happened to overlap exactly with an expansion. The combining behaviour only makes sense for code regions. llvm-svn: 229723
2015-02-18InstrProf: Handle unknown functions if they consist only of zero-regionsJustin Bogner1-0/+13
This comes up when we generate coverage for a function but don't end up emitting the function at all - dead static functions or inline functions that aren't referenced in a particular TU, for example. In these cases we'd like to show that the function was never called, which is trivially true. llvm-svn: 229717
2015-02-18InstrProf: Make CoverageMapping testable and add a basic unit testJustin Bogner1-0/+82
Make CoverageMapping easier to create, so that we can write targeted unit tests for its internals, and add a some infrastructure to write these tests. Finally, add a simple unit test for basic functionality. llvm-svn: 229709
2015-02-17Re-apply "InstrProf: Use a test fixture in the coverage mapping tests"Justin Bogner1-67/+81
This time we use a helper to format the assertion so we can just use ASSERT_TRUE instead of relying on ASSERT_EQ being able to deal with conversions between enum types. This reverts r229496, re-applying r229473. llvm-svn: 229547