aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-08-02[coverage] Make smaller regions for the first case of a switch.Eli Friedman1-6/+13
We never overwrite the end location of a region, so we would end up with an overly large region when we reused the switch's region. It's possible this code will be substantially rewritten in the near future to deal with fallthrough more accurately, but this seems like an improvement on its own for now. Differential Revision: https://reviews.llvm.org/D34801 llvm-svn: 309901
2017-07-27[Coverage] NFC: Simplify sanity checks with a SpellingRange utilityVedant Kumar1-21/+41
This should simplify D35925. llvm-svn: 309245
2017-07-27[Coverage] NFC: Save a pair of calls to get{Start,End}Vedant Kumar1-3/+5
llvm-svn: 309244
2017-04-15[Coverage] Use the new getInstrProfSectionName API (NFC)Vedant Kumar1-1/+3
llvm-svn: 300382
2017-04-14Fix use after free errorXinliang David Li1-1/+1
llvm-svn: 300304
2017-04-14Remove unused function /nfcXinliang David Li1-4/+0
llvm-svn: 300301
2017-04-13[Profile] PE binary coverage bug fixXinliang David Li1-1/+1
PR/32584 Differential Revision: https://reviews.llvm.org/D32023 llvm-svn: 300279
2016-11-07Fix use-of-temporary with StringRef in code coverageJordan Rose1-2/+7
The fixed code is basically identical to the same loop below, which might indicate an opportunity for refactoring. I just wanted to fix the use-of-temporary issue. Caught by adding a similar check to StringRef as r283798 did for ArrayRef. I'll be upstreaming that soon. Reviewed by Vedant Kumar as https://reviews.llvm.org/D26317. llvm-svn: 286122
2016-10-14[Coverage] Support for C++17 if initializersVedant Kumar1-0/+3
Differential Revision: https://reviews.llvm.org/D25572 llvm-svn: 284293
2016-10-14[Coverage] Support for C++17 switch initializersVedant Kumar1-0/+2
Differential Revision: https://reviews.llvm.org/D25539 llvm-svn: 284292
2016-10-01Use StringRef for MemoryBuffer identifier API (NFC)Mehdi Amini1-1/+1
llvm-svn: 283043
2016-09-27[Coverage] The coverage region for switch covers the code after the switch.Alex Lorenz1-1/+5
This patch fixes a regression introduced in r262697 that changed the way the coverage regions for switches are constructed. The PGO instrumentation counter for a switch statement refers to the counter at the exit of the switch. Therefore, the coverage region for the switch statement should cover the code that comes after the switch, and not the switch statement itself. rdar://28480997 Differential Revision: https://reviews.llvm.org/D24981 llvm-svn: 282554
2016-08-31[Coverage] Suppress creating a code region if the same area is covered by an ↵Igor Kudrin1-5/+23
expansion region. In most cases these code regions are just redundant, but sometimes they could be assigned to the counter of the parent code region instead of the counter of the nested block. Differential Revision: https://reviews.llvm.org/D23987 llvm-svn: 280199
2016-08-29[Coverage] Prevent creating a redundant counter if a nested body ends with a ↵Igor Kudrin1-1/+2
macro. If there were several nested statements arranged in a way that all of them end up with the same macro, then the expansion of this macro was assigned with all the corresponding counters of these statements. As a result, the wrong counter value was shown for the macro in llvm-cov. This patch fixes the issue by preventing adding a counter for an expanded source range if it already has an assigned counter, which is expected to come from the most specific statement. Differential Revision: https://reviews.llvm.org/D23160 llvm-svn: 279962
2016-07-26[Coverage] Do not write out coverage mappings with zero entriesVedant Kumar1-0/+11
After r275121, we stopped mapping regions from system headers. Lambdas declared in regions belonging to system headers started producing empty coverage mappings, since the files corresponding to their spelling locs were being ignored. The coverage reader doesn't know what to do with these empty mappings. This commit makes sure that we don't produce them and adds a test. I'll make the reader stricter in a follow-up commit. llvm-svn: 276716
2016-07-18[Coverage] Remove '..' from filenames *after* getting an absolute pathVedant Kumar1-1/+1
Failure to do this breaks relative paths which begin with '..'. This issue was caught by the (still nascent) coverage bot. llvm-svn: 275924
2016-07-18[Coverage] Normalize '..' out of filename stringsVedant Kumar1-8/+14
This fixes the issue of having duplicate entries for the same file in a coverage report s.t none of the entries actually displayed the correct coverage information. llvm-svn: 275913
2016-07-11[Coverage] Do not map regions from system headersVedant Kumar1-0/+8
Do not assign source regions located within system headers file ID's, and do not construct counter mapping regions out of them. This makes coverage reports less cluttered and less mysterious. E.g using the "assert" macro doesn't cause assert.h to appear in reports, and it no longer shows the "assertion failed" branch as an uncovered region. It also makes coverage mapping sections a bit smaller (e.g a 1% reduction in a stage2 build of bin/llvm-as). llvm-svn: 275121
2016-07-06Delete some dead code, NFCVedant Kumar1-10/+0
Found using clang's code coverage tool. llvm-svn: 274599
2016-06-29Revert "[Coverage] Adopt llvm::coverage::encodeFilenamesAndRawMappings (NFC)"Vedant Kumar1-10/+18
This reverts commit 161ff9db3a3d0d62880d1cb18d58182cd3034912 (r273056). This is breaking stage2 instrumented builds with "malformed coverage data" errors. llvm-svn: 274104
2016-06-22[Coverage] Push a new region when handling CXXTryStmtsVedant Kumar1-1/+6
Push a new region for the try block and propagate execution counts through it. This ensures that catch statements get a region counter distinct from the try block's counter. llvm-svn: 273463
2016-06-17[Coverage] Adopt llvm::coverage::encodeFilenamesAndRawMappings (NFC)Vedant Kumar1-18/+10
Use an llvm helper function to encode filenames and raw mappings. llvm-svn: 273056
2016-06-07Reapply [Coverage] Fix an assertion failure if the definition of an unused ↵Igor Kudrin1-11/+31
function spans multiple files. We have an assertion failure if, for example, the definition of an unused inline function starts in one macro and ends in another. This patch fixes the issue by finding the common ancestor of the start and end locations of that function's body and changing the locations accordingly. Thanks to NAKAMURA Takumi for helping with fixing the test failure on Windows. Differential Revision: http://reviews.llvm.org/D20997 llvm-svn: 271995
2016-06-07Revert [Coverage] Fix an assertion failure if the definition of an unused ↵Igor Kudrin1-31/+11
function spans multiple files. r271969 The test case fails on Windows. llvm-svn: 271976
2016-06-07[Coverage] Fix an assertion failure if the definition of an unused function ↵Igor Kudrin1-11/+31
spans multiple files. We have an assertion failure if, for example, the definition of an unused inline function starts in one macro and ends in another. This patch fixes the issue by finding the common ancestor of the start and end locations of that function's body and changing the locations accordingly. Differential Revision: http://reviews.llvm.org/D20997 llvm-svn: 271969
2016-05-31[Coverage] Remove redundant handleFileExit() call (NFC)Vedant Kumar1-3/+1
I added this call in r271308. It's redundant because it's dominated by a call to extendRegion(). Thanks to Justin Bogner for pointing this out! llvm-svn: 271331
2016-05-31[Coverage] Fix crash on a switch partially covered by a macro (PR27948)Vedant Kumar1-2/+6
We have to handle file exits before and after visiting regions in the switch body. Fixes PR27948. llvm-svn: 271308
2016-05-04[Coverage] Fix an issue where a coverage region might not be created for a ↵Igor Kudrin1-3/+19
macro containing a loop statement. The issue happened when a macro contained a full for or while statement, which body ended at the end of the macro. Differential Revision: http://reviews.llvm.org/D19725 llvm-svn: 268511
2016-04-29Use the new path for coverage related headers and update CMakeLists.txtEaswaran Raman1-3/+3
Differential Revision: http://reviews.llvm.org/D19612 llvm-svn: 268090
2016-03-04[Coverage] Fix the start/end locations of switch statementsVedant Kumar1-1/+1
While pushing switch statements onto the region stack we neglected to specify their start/end locations. This results in a crash (PR26825) if we end up in nested macro expansions without enough information to handle the relevant file exits. I added a test in switchmacro.c and fixed up a bunch of incorrect CHECK lines that specify strange end locations for switches. llvm-svn: 262697
2016-02-08[Coverage] Fix crash when handling certain macro expansionsVedant Kumar1-0/+6
When handling 'if' statements, we crash if the condition and the consequent branch are spanned by a single macro expansion. The crash occurs because of a sanity 'reset' in popRegions(): if an expansion exactly spans an entire region, we set MostRecentLocation to the start of the expansion (its 'include location'). This ensures we don't handleFileExit() ourselves out of the expansion before we're done processing all of the regions within it. This is tested in test/CoverageMapping/macro-expressions.c. This causes a problem when an expansion spans both the condition and the consequent branch of an 'if' statement. MostRecentLocation is updated to the start of the 'if' statement in popRegions(), so the file for the expansion isn't exited by the time we're done handling the statement. We then crash with 'fatal: File exit not handled before popRegions'. The fix for this is to detect these kinds of expansions, and conservatively update MostRecentLocation to the end of expansion region containing the conditional. I've added tests to make sure we don't have the same problem with other kinds of statements. rdar://problem/23630316 Differential Revision: http://reviews.llvm.org/D16934 llvm-svn: 260129
2016-01-28[Coverage] Use a set to track visited FileIDs (NFC)Vedant Kumar1-3/+3
llvm-svn: 259061
2016-01-21[Coverage] Reduce complexity of adding function mapping recordsVedant Kumar1-3/+6
Replace a string append operation in addFunctionMappingRecord with a vector append. The existing behavior is quadratic in the worst case: this patch makes it linear. Differential Revision: http://reviews.llvm.org/D16395 llvm-svn: 258424
2016-01-20Reference the updated function name /NFCXinliang David Li1-1/+1
llvm-svn: 258261
2016-01-19Fix local variable name /NFCXinliang David Li1-2/+2
llvm-svn: 258106
2016-01-07[PGO] Simplify coverage mapping loweringXinliang David Li1-3/+17
Coverage mapping data may reference names of functions that are skipped by FE (e.g, unused inline functions). Since those functions are skipped, normal instr-prof function lowering pass won't put those names in the right section, so special handling is needed to walk through coverage mapping structure and recollect the references. With this patch, only names that are skipped are processed. This simplifies the lowering code and it no longer needs to make assumptions coverage mapping data layout. It should also be more efficient. llvm-svn: 257092
2016-01-03[PGO] Cleanup: Use covmap header definition in the template fileXinliang David Li1-14/+20
This is one last remaining instrumentatation related structure that needs to be migrate to use the centralized template definition. With this change, instrumentation code related to coverage module header will be kept in sync with the coverage mapping reader. The remaining code which makes implicit assumption about covmap control structure layout in the the lowering pass will cleaned up in a different patch. This patch is not intended to have no functional change. llvm-svn: 256714
2015-12-24use auto for obvious type; NFCSanjay Patel1-1/+1
llvm-svn: 256393
2015-11-05Use profile data template file for covmap func record (NFC)Xinliang David Li1-11/+10
llvm-svn: 252147
2015-10-22Use newly introduced interfaces in LLVM (NFC)Xinliang David Li1-2/+2
Replaced references to raw strings in instrumentation and coverage code. llvm-svn: 251072
2015-10-03Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren1-1/+1
+couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
2015-10-03Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren1-2/+2
SourceLocation.isValid(). llvm-svn: 249228
2015-09-26Remove move constructor and assignment operator from SourceMappingRegion. ↵Craig Topper1-12/+1
The types of the fields are trivially copyable. NFC llvm-svn: 248659
2015-09-26Fix a couple other places that were returning SourceLocation by reference. NFCCraig Topper1-2/+2
llvm-svn: 248658
2015-07-30Use llvm::reverse to make a bunch of loops use foreach. NFC.Pete Cooper1-6/+6
In llvm commit r243581, a reverse range adapter was added which allows us to change code such as for (auto I = Fields.rbegin(), E = Fields.rend(); I != E; ++I) { in to for (const FieldDecl *I : llvm::reverse(Fields)) This commit changes a few of the places in clang which are eligible to use this new adapter. llvm-svn: 243663
2015-07-23InstrProf: Don't extend coverage regions into the catch keywordJustin Bogner1-1/+0
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-17InstrProf: Promote this assert to a report_fatal_errorJustin Bogner1-2/+2
If this assert does fire, the no-asserts behaviour is an infinite loop. It's better to crash in this case so we get a crash report and stop wasting the user's cpu cycles. llvm-svn: 242591
2015-07-02Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer1-4/+3
++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
2015-07-02InstrProf: Add a comment to clarify an argumentJustin Bogner1-1/+2
llvm-svn: 241296
2015-07-02InstrProf: Pack the coverage mapping structs that we write outJustin Bogner1-1/+1
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