summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Coverage] Remove redundant handleFileExit() call (NFC)Vedant Kumar2016-05-311-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
* [Coverage] Fix crash on a switch partially covered by a macro (PR27948)Vedant Kumar2016-05-311-2/+6
| | | | | | | We have to handle file exits before and after visiting regions in the switch body. Fixes PR27948. llvm-svn: 271308
* [Coverage] Fix an issue where a coverage region might not be created for a ↵Igor Kudrin2016-05-041-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
* Use the new path for coverage related headers and update CMakeLists.txtEaswaran Raman2016-04-291-3/+3
| | | | | | Differential Revision: http://reviews.llvm.org/D19612 llvm-svn: 268090
* [Coverage] Fix the start/end locations of switch statementsVedant Kumar2016-03-041-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
* [Coverage] Fix crash when handling certain macro expansionsVedant Kumar2016-02-081-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
* [Coverage] Use a set to track visited FileIDs (NFC)Vedant Kumar2016-01-281-3/+3
| | | | llvm-svn: 259061
* [Coverage] Reduce complexity of adding function mapping recordsVedant Kumar2016-01-211-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
* Reference the updated function name /NFCXinliang David Li2016-01-201-1/+1
| | | | llvm-svn: 258261
* Fix local variable name /NFCXinliang David Li2016-01-191-2/+2
| | | | llvm-svn: 258106
* [PGO] Simplify coverage mapping loweringXinliang David Li2016-01-071-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
* [PGO] Cleanup: Use covmap header definition in the template fileXinliang David Li2016-01-031-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
* use auto for obvious type; NFCSanjay Patel2015-12-241-1/+1
| | | | llvm-svn: 256393
* Use profile data template file for covmap func record (NFC)Xinliang David Li2015-11-051-11/+10
| | | | llvm-svn: 252147
* Use newly introduced interfaces in LLVM (NFC)Xinliang David Li2015-10-221-2/+2
| | | | | | | Replaced references to raw strings in instrumentation and coverage code. llvm-svn: 251072
* Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren2015-10-031-1/+1
| | | | | | +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
* Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren2015-10-031-2/+2
| | | | | | SourceLocation.isValid(). llvm-svn: 249228
* Remove move constructor and assignment operator from SourceMappingRegion. ↵Craig Topper2015-09-261-12/+1
| | | | | | The types of the fields are trivially copyable. NFC llvm-svn: 248659
* Fix a couple other places that were returning SourceLocation by reference. NFCCraig Topper2015-09-261-2/+2
| | | | llvm-svn: 248658
* Use llvm::reverse to make a bunch of loops use foreach. NFC.Pete Cooper2015-07-301-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
* InstrProf: Don't extend coverage regions into the catch keywordJustin Bogner2015-07-231-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
* InstrProf: Promote this assert to a report_fatal_errorJustin Bogner2015-07-171-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
* Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer2015-07-021-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
* InstrProf: Add a comment to clarify an argumentJustin Bogner2015-07-021-1/+2
| | | | llvm-svn: 241296
* InstrProf: Pack the coverage mapping structs that we write outJustin Bogner2015-07-021-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
* InstrProf: Fix a crash when an implicit def appears in a macroJustin Bogner2015-06-231-1/+2
| | | | llvm-svn: 240452
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* InstrProf: Fix coverage mapping when "if" is a macroJustin Bogner2015-06-161-0/+3
| | | | | | | | | 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
* InstrProf: Only disable coverage in built-in macros, not all system macrosJustin Bogner2015-05-141-4/+9
| | | | | | | | | 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
* InstrProf: Don't start or end coverage regions inside of system macrosJustin Bogner2015-05-051-4/+4
| | | | | | | | | | | 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
* InstrProf: Fix a coverage crash where a macro begins in an unreachable blockJustin Bogner2015-05-011-1/+4
| | | | llvm-svn: 236335
* Fix -Wpessimizing-move by removing call to std::moveRichard Trieu2015-04-301-1/+1
| | | | llvm-svn: 236281
* InstrProf: Make sure coverage propagates out of foreach loops correctlyJustin Bogner2015-04-301-4/+8
| | | | llvm-svn: 236264
* InstrProf: Mark code regions after throw expressions as unreachableJustin Bogner2015-04-281-0/+7
| | | | | | | We weren't setting regions as being unreachable after C++ throw expressions, leading to incorrect count propagations. llvm-svn: 235967
* InstrProf: Fix coverage maps for conditional operatorsJustin Bogner2015-04-241-1/+7
| | | | | | | | | 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
* Change range-based for-loops to be -Wrange-loop-analysis clean.Richard Trieu2015-04-151-1/+1
| | | | | | No functionality change. llvm-svn: 234964
* InstrProf: Handle whitespace and comments at the ends of macrosJustin Bogner2015-03-251-4/+4
| | | | | | | | | | | | | | | 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
* InstrProf: Make sure counts in lambdas don't escape to the parent scopeJustin Bogner2015-02-241-0/+5
| | | | | | | | 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
* InstrProf: Always emit a coverage region for the condition of an ifJustin Bogner2015-02-191-1/+4
| | | | | | | | 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
* InstrProf: Rewrite most of coverage mapping generation in a simpler wayJustin Bogner2015-02-181-660/+516
| | | | | | | | | | | | | | | | | | | | | | | 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
* InstrProf: Update for LLVM API changeJustin Bogner2015-02-031-9/+7
| | | | | | Update for the API change in r228075 llvm-svn: 228076
* InstrProf: Remove CoverageMapping::HasCodeBefore, it isn't usedJustin Bogner2015-02-031-14/+11
| | | | llvm-svn: 228035
* InstrProf: Update for LLVM API changeJustin Bogner2015-02-031-10/+10
| | | | | | Update for the change in r227900. llvm-svn: 227901
* InstrProf: Use an Optional instead of an out parameterJustin Bogner2015-01-241-32/+27
| | | | llvm-svn: 227015
* InstrProf: Use the stream when dumping countersJustin Bogner2015-01-231-1/+1
| | | | llvm-svn: 226968
* [cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.pyChandler Carruth2015-01-141-2/+2
| | | | | | | | | | Sorry for the noise, I managed to miss a bunch of recent regressions of include orderings here. This should actually sort all the includes for Clang. Again, no functionality changed, this is just a mechanical cleanup that I try to run periodically to keep the #include lines as regular as possible across the project. llvm-svn: 225979
* InstrProf: Simplify/reduce state in CoverageMapping (NFC)Justin Bogner2014-12-171-38/+2
| | | | | | | | This state object makes things harder to reason about and isn't really useful, since we can just emit the mappings before the state changes rather than holding on to it. llvm-svn: 224476
* InstrProf: Remove an unnecessary helper function (NFC)Justin Bogner2014-11-111-26/+12
| | | | | | | VisitSubStmtRBraceState is really just Visit, as long as VisitCompoundStatement handles braces correctly. llvm-svn: 221659
* Reapply "InstrProf: Update for the LLVM API change in r218879"Justin Bogner2014-10-021-6/+3
| | | | | | | | Reapplying now that r218887 is in. This reverts commit r218882, reapplying r218880. llvm-svn: 218888
OpenPOWER on IntegriCloud