summaryrefslogtreecommitdiffstats
path: root/clang/test/CoverageMapping
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[Coverage] Revise format to reduce binary size"Vedant Kumar2019-12-042-24/+5
| | | | | | | | | | This reverts commit e18531595bba495946aa52c0a16b9f9238cff8bc. On Windows, there is an error: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/54963/steps/stage%201%20check/logs/stdio error: C:\b\slave\sanitizer-windows\build\stage1\projects\compiler-rt\test\profile\Profile-x86_64\Output\instrprof-merging.cpp.tmp.v1.o: Failed to load coverage: Malformed coverage data
* [Coverage] Revise format to reduce binary sizeVedant Kumar2019-12-042-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revise the coverage mapping format to reduce binary size by: 1. Naming function records and marking them `linkonce_odr`, and 2. Compressing filenames. This shrinks the size of llc's coverage segment by 82% (334MB -> 62MB) and speeds up end-to-end single-threaded report generation by 10%. For reference the compressed name data in llc is 81MB (__llvm_prf_names). Rationale for changes to the format: - With the current format, most coverage function records are discarded. E.g., more than 97% of the records in llc are *duplicate* placeholders for functions visible-but-not-used in TUs. Placeholders *are* used to show under-covered functions, but duplicate placeholders waste space. - We reached general consensus about giving (1) a try at the 2017 code coverage BoF [1]. The thinking was that using `linkonce_odr` to merge duplicates is simpler than alternatives like teaching build systems about a coverage-aware database/module/etc on the side. - Revising the format is expensive due to the backwards compatibility requirement, so we might as well compress filenames while we're at it. This shrinks the encoded filenames in llc by 86% (12MB -> 1.6MB). See CoverageMappingFormat.rst for the details on what exactly has changed. Fixes PR34533 [2], hopefully. [1] http://lists.llvm.org/pipermail/llvm-dev/2017-October/118428.html [2] https://bugs.llvm.org/show_bug.cgi?id=34533 Differential Revision: https://reviews.llvm.org/D69471
* [Coverage] Emit a gap region to cover switch bodiesVedant Kumar2019-12-032-11/+24
| | | | | | | | | | | | | | Emit a gap region beginning where the switch body begins. This sets line execution counts in the areas between non-overlapping cases to 0. This also removes some special handling of the first case in a switch: these are now treated like any other case. This does not resolve an outstanding issue with case statement regions that do not end when a region is terminated. But it should address llvm.org/PR44011. Differential Revision: https://reviews.llvm.org/D70571
* Revert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"Reid Kleckner2019-10-281-16/+0
| | | | | | | This reverts commit 9d4806a387892972fd544c0dcaefb0926126220c. There seem to be bugs in llvm-cov --path-equivalence that are causing Chromium problems. Revert this until they are understood or fixed.
* Fix one more clang test which didn't have \5C in itReid Kleckner2019-10-101-1/+1
| | | | llvm-svn: 374418
* Re-land "Use -fdebug-compilation-dir to form absolute paths in coverage ↵Reid Kleckner2019-10-101-0/+16
| | | | | | | | | | | | mappings" This reverts r374324 (git commit 62808631acceaa8b78f8ab9b407eb6b943ff5f77) I changed the test to not rely on finding the sequence "clang, test, CoverageMapping" in the CWD used to run the test. Instead it makes its own internal directory hierarchy of foo/bar/baz and looks for that. llvm-svn: 374403
* Revert "Use -fdebug-compilation-dir to form absolute paths in coverage mappings"Kadir Cetinkaya2019-10-101-16/+0
| | | | | | | | | | | | This reverts commit f6777964bde28c349d3e289ea37ecf5f5eeedbc4. Because the absolute path check relies on temporary path containing "clang", "test" and "CoverageMapping" as a subsequence, which is not necessarily true on all systems(breaks internal integrates). Wanted to fix it by checking for a leading "/" instead, but then noticed that it would break windows tests, so leaving it to the author instead. llvm-svn: 374324
* Use -fdebug-compilation-dir to form absolute paths in coverage mappingsReid Kleckner2019-10-101-0/+16
| | | | | | | | | | | | | This allows users to explicitly request relative paths with `-fdebug-compilation-dir .`. Fixes PR43614 Reviewers: vsk, arphaman Differential Revision: https://reviews.llvm.org/D68733 llvm-svn: 374266
* Remove cache for macro arg stringizationReid Kleckner2019-07-301-0/+30
| | | | | | | | | | | | | | | | | | | Summary: The cache recorded the wrong expansion location for all but the first stringization. It seems uncommon to stringize the same macro argument multiple times, so this cache doesn't seem that important. Fixes PR39942 Reviewers: vsk, rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65428 llvm-svn: 367337
* Fix clang tests broken by r353547 that depend on InstrProfReid Kleckner2019-02-101-1/+1
| | | | llvm-svn: 353653
* [Coverage] Specify the Itanium ABI triple for a C++ testVedant Kumar2018-11-281-1/+1
| | | | llvm-svn: 347804
* [Coverage] Do not visit artificial stmts in defaulted methods (PR39822)Vedant Kumar2018-11-281-0/+17
| | | | | | | | | | | | | | | | | | | | | | There is no reason to emit coverage mappings for artificial statements contained within defaulted methods, as these statements are not visible to users. Only emit a mapping for the body of the defaulted method (clang treats the text of the "default" keyword as the body when reporting locations). This allows users to see how often the default method is called, but trims down the coverage mapping by skipping visitation of the children of the method. The immediate motivation for this change is that the lexer's getPreciseTokenLocEnd API cannot return the correct location when given an artificial statement (with a somewhat made-up location) as an input. Test by Orivej Desh! Fixes llvm.org/PR39822. llvm-svn: 347803
* [Coverage] Fix PR39258: support coverage regions that start deeper than they endVedant Kumar2018-11-191-0/+10
| | | | | | | | | | | popRegions used to assume that the start location of a region can't be nested deeper than the end location, which is not always true. Patch by Orivej Desh! Differential Revision: https://reviews.llvm.org/D53244 llvm-svn: 347262
* [OPENMP] Fix PR38256: Fix locations of the artificial conditional op.Alexey Bataev2018-07-251-0/+12
| | | | | | | Fixed the source locations of the conditional op so that they don'r crash coverage pass. llvm-svn: 337928
* [Coverage] Remove a test dependency on the itanium ABIVedant Kumar2018-06-011-10/+11
| | | | | | | This should address a bot failure: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/9994/ llvm-svn: 333775
* [Coverage] End deferred regions before labels, fixes PR35867Vedant Kumar2018-06-011-0/+9
| | | | | | | | | A deferred region should end before the start of a label, and should not extend to the start of the label sub-statement. Fixes llvm.org/PR35867. llvm-svn: 333715
* [Coverage] Discard the last uncompleted deferred region in a declVedant Kumar2018-05-304-11/+22
| | | | | | | | | | | | | | | | | | | Discard the last uncompleted deferred region in a decl, if one exists. This prevents lines at the end of a function containing only whitespace or closing braces from being marked as uncovered, if they follow a region terminator (return/break/etc). The previous behavior was to heuristically complete deferred regions at the end of a decl. In practice this ended up being too brittle for too little gain. Users would complain that there was no way to reach full code coverage because whitespace at the end of a function would be marked uncovered. rdar://40238228 Differential Revision: https://reviews.llvm.org/D46918 llvm-svn: 333609
* [Coverage] Handle break/continue outside of loop bodiesVedant Kumar2018-02-161-0/+11
| | | | | | | | | Teach the coverage mapping logic to handle break or continue statements within for loop increments. Fixes llvm.org/PR36406. llvm-svn: 325319
* [Parse] Forward brace locations to TypeConstructExprVedant Kumar2018-01-171-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | When parsing C++ type construction expressions with list initialization, forward the locations of the braces to Sema. Without these locations, the code coverage pass crashes on the given test case, because the pass relies on getLocEnd() returning a valid location. Here is what this patch does in more detail: - Forwards init-list brace locations to Sema (ParseExprCXX), - Builds an InitializationKind with these locations (SemaExprCXX), and - Uses these locations for constructor initialization (SemaInit). The remaining changes fall out of introducing a new overload for creating direct-list InitializationKinds. Testing: check-clang, and a stage2 coverage-enabled build of clang with asserts enabled. Differential Revision: https://reviews.llvm.org/D41921 llvm-svn: 322729
* [Coverage] Emit gap areas in braces-optional statements (PR35387)Vedant Kumar2017-11-2912-47/+57
| | | | | | | | | | | | Emit a gap area starting after the r-paren location and ending at the start of the body for the braces-optional statements (for, for-each, while, etc). The count for the gap area equal to the body's count. This extends the fix in r317758. Fixes PR35387, rdar://35570345 Testing: stage2 coverage-enabled build of clang, check-clang llvm-svn: 319373
* [Coverage] Emit deferred regions in headersVedant Kumar2017-11-092-1/+17
| | | | | | | | | | | There are some limitations with emitting regions in macro expansions because we don't gather file IDs within the expansions. Fix the check that prevents us from emitting deferred regions in expansions to make an exception for headers, which is something we can handle. rdar://35373009 llvm-svn: 317760
* [Coverage] Complete top-level deferred regions before labelsVedant Kumar2017-11-092-4/+4
| | | | | | | | | | | | | | | | | | | The area immediately after a terminated region in the function top-level should have the same count as the label it precedes. This solves another problem with wrapped segments. Consider: 1| a: 2| return 0; 3| b: 4| return 1; Without a gap area starting after the first return, the wrapped segment from line 2 would make it look like line 3 is executed, when it's not. rdar://35373009 llvm-svn: 317759
* [Coverage] Emit a gap area after if conditionsVedant Kumar2017-11-0917-65/+71
| | | | | | | | | | | | | | | | | | | The area immediately after the closing right-paren of an if condition should have a count equal to the 'then' block's count. Use a gap region to set this count, so that region highlighting for the 'then' block remains precise. This solves a problem we have with wrapped segments. Consider: 1| if (false) 2| foo(); Without a gap area starting after the condition, the wrapped segment from line 1 would make it look like line 2 is executed, when it's not. rdar://35373009 llvm-svn: 317758
* [Coverage] Discard deferred region in closing if-elseVedant Kumar2017-10-171-1/+21
| | | | | | | | | | | | | | | | A trailing deferred region isn't necessary in a function that ends with this pattern: ... else { ... return; } Special-case this pattern so that the closing curly brace of the function isn't marked as uncovered. This issue came up in PR34962. llvm-svn: 315982
* [Coverage] Explicitly mark the l.h.s of && and || (fixes PR33465)Vedant Kumar2017-10-172-7/+14
| | | | | | | | | | This makes it possible to view sub-line region counts for the l.h.s of && and || expressions in coverage reports. It also fixes PR33465, which shows an example of incorrect coverage output for an assignment statement containing '||'. llvm-svn: 315979
* [Coverage] Add an option to emit limited coverage infoVedant Kumar2017-09-221-0/+5
| | | | | | | | | | | | | | | | | | | | | Add an option to emit limited coverage info for unused decls. It's just a cl::opt for now to allow us to experiment quickly. When building llc, this results in an 84% size reduction in the llvm_covmap section, and a similar size reduction in the llvm_prf_names section. In practice I expect the size reduction to be roughly quadratic with the size of the program. The downside is that coverage for headers will no longer be complete. This will make the line/function/region coverage metrics incorrect, since they will be artificially high. One mitigation would be to somehow disable those metrics when using limited-coverage=true. This is related to: llvm.org/PR34533 (make SourceBasedCodeCoverage scale) Differential Revision: https://reviews.llvm.org/D38107 llvm-svn: 314002
* [Coverage] Remove deferred region for trailing return, fixes PR34611Vedant Kumar2017-09-191-0/+8
| | | | | | | | As a special case, throw away deferred regions for trailing returns. This allows the closing curly brace to have a count, and is less distracting. llvm-svn: 313603
* [Coverage] Use a new API to label gap areasVedant Kumar2017-09-181-18/+18
| | | | | | | This will make it possible for llvm-cov to pick better line execution counts, and is part of the fix for llvm.org/PR34612. llvm-svn: 313598
* [Lexer] Report more precise skipped regions (PR34166)Vedant Kumar2017-09-111-10/+43
| | | | | | | | | | | | | | | | | | | | This patch teaches the preprocessor to report more precise source ranges for code that is skipped due to conditional directives. The new behavior includes the '#' from the opening directive and the full text of the line containing the closing directive in the skipped area. This matches up clang's behavior (we don't IRGen the code between the closing "endif" and the end of a line). This also affects the code coverage implementation. See llvm.org/PR34166 (this also happens to be rdar://problem/23224058). The old behavior (report the end of the skipped range as the end location of the 'endif' token) is preserved for indexing clients. Differential Revision: https://reviews.llvm.org/D36642 llvm-svn: 312947
* [Coverage] Precise region termination with deferred regions (reapply)Vedant Kumar2017-09-087-17/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current coverage implementation doesn't handle region termination very precisely. Take for example an `if' statement with a `return': void f() { if (true) { return; // The `if' body's region is terminated here. } // This line gets the same coverage as the `if' condition. } If the function `f' is called, the line containing the comment will be marked as having executed once, which is not correct. The solution here is to create a deferred region after terminating a region. The deferred region is completed once the start location of the next statement is known, and is then pushed onto the region stack. In the cases where it's not possible to complete a deferred region, it can safely be dropped. Testing: lit test updates, a stage2 coverage-enabled build of clang This is a reapplication but there are no changes from the original commit. With D36813, the segment builder in llvm will be able to handle deferred regions correctly. llvm-svn: 312818
* [clang] Get rid of "%T" expansionsKuba Mracek2017-08-151-1/+1
| | | | | | | | | | The %T lit expansion expands to a common directory shared between all the tests in the same directory, which is unexpected and unintuitive, and more importantly, it's been a source of subtle race conditions and flaky tests. In https://reviews.llvm.org/D35396, it was agreed that it would be best to simply ban %T and only keep %t, which is unique to each test. When a test needs a temporary directory, it can just create one using mkdir %t. This patch removes %T in clang. Differential Revision: https://reviews.llvm.org/D36437 llvm-svn: 310950
* [coverage] Special-case calls to noreturn functions.Eli Friedman2017-08-082-0/+24
| | | | | | | | | | | | | | | The code after a noreturn call doesn't execute. The pattern in the testcase is pretty common in LLVM (a switch with a default case that calls llvm_unreachable). The original version of this patch was reverted in r309995 due to a crash. This version includes a fix for that crash (testcase in test/CoverageMapping/md.cpp). Differential Revision: https://reviews.llvm.org/D36250 llvm-svn: 310406
* Revert "[Coverage] Precise region termination with deferred regions"Vedant Kumar2017-08-057-167/+17
| | | | | | | | | | | | | | This reverts commit r310010. I don't think there's anything wrong with this commit, but it's causing clang to generate output that llvm-cov doesn't do a good job with and the fix isn't immediately clear. See Eli's comment in D36250 for more context. I'm reverting the clang change so the coverage bot can revert back to producing sensible output, and to give myself some time to investigate what went wrong in llvm. llvm-svn: 310154
* Revert "[coverage] Special-case calls to noreturn functions."Vedant Kumar2017-08-041-13/+0
| | | | | | | | | | | This reverts commit r309995. It looks like it's responsible for breaking the stage2 coverage build: http://green.lab.llvm.org/green/job/clang-stage2-coverage-R_build/1402 The cfe-commits discussion re: r309995 has more context. llvm-svn: 310019
* [Coverage] Precise region termination with deferred regionsVedant Kumar2017-08-047-17/+167
| | | | | | | | | | | | | | | | | | | | | | | | The current coverage implementation doesn't handle region termination very precisely. Take for example an `if' statement with a `return': void f() { if (true) { return; // The `if' body's region is terminated here. } // This line gets the same coverage as the `if' condition. } If the function `f' is called, the line containing the comment will be marked as having executed once, which is not correct. The solution here is to create a deferred region after terminating a region. The deferred region is completed once the start location of the next statement is known, and is then pushed onto the region stack. In the cases where it's not possible to complete a deferred region, it can safely be dropped. Testing: lit test updates, a stage2 coverage-enabled build of clang llvm-svn: 310010
* [coverage] Special-case calls to noreturn functions.Eli Friedman2017-08-031-0/+13
| | | | | | | | | | | The code after a noreturn call doesn't execute. The pattern in the testcase is pretty common in LLVM (a switch with a default case that calls llvm_unreachable). Differential Revision: https://reviews.llvm.org/D36250 llvm-svn: 309995
* [coverage] Make smaller regions for the first case of a switch.Eli Friedman2017-08-021-3/+19
| | | | | | | | | | | | | 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
* [Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761)Vedant Kumar2017-04-241-0/+11
| | | | | | | | Patch by Adam Folwarczny! Differential Revision: https://reviews.llvm.org/D32406 llvm-svn: 301249
* [Coverage] Don't emit mappings for functions in dependent contexts (fixes ↵Vedant Kumar2017-04-191-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PR32679) The coverage implementation marks functions which won't be emitted as 'deferred', so that it can emit empty coverage regions for them later (once their linkages are known). Functions in dependent contexts are an exception: if there isn't a full instantiation of a function, it shouldn't be marked 'deferred'. We've been breaking that rule without much consequence because we just ended up with useless, extra, empty coverage mappings. With PR32679, this behavior finally caused a crash, because clang marked a partial template specialization as 'deferred', causing the MS mangler to choke in its delayed-template-parsing mode: error: cannot mangle this template type parameter type yet (http://bugs.llvm.org/show_bug.cgi?id=32679) Fix this by checking if a decl's context is a dependent context before marking it 'deferred'. Based on a patch by Adam Folwarczny! Differential Revision: https://reviews.llvm.org/D32144 llvm-svn: 300723
* clang/test/CoverageMapping/unused_names.c: Relax an expression for targeting ↵NAKAMURA Takumi2017-04-141-1/+1
| | | | | | PECOFF. llvm-svn: 300303
* Suppress uninteresting warnings in test/CoverageMapping, NFC.Vedant Kumar2017-02-253-3/+3
| | | | llvm-svn: 296247
* [profiling] Update test cases to deal with name variable change (NFC)Vedant Kumar2017-02-141-6/+7
| | | | | | | | | This is a re-try of r295085: fix up some test cases that assume that profile name variables are preserved by the instrprof pass. This catches one additional case in test/CoverageMapping/unused_names.c. llvm-svn: 295101
* [Coverage] Support for C++17 if initializersVedant Kumar2016-10-141-1/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D25572 llvm-svn: 284293
* [Coverage] Support for C++17 switch initializersVedant Kumar2016-10-141-6/+16
| | | | | | Differential Revision: https://reviews.llvm.org/D25539 llvm-svn: 284292
* [Coverage] The coverage region for switch covers the code after the switch.Alex Lorenz2016-09-272-13/+13
| | | | | | | | | | | | | | 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
* [Coverage] Suppress creating a code region if the same area is covered by an ↵Igor Kudrin2016-08-312-7/+10
| | | | | | | | | | | | 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
* [Coverage] Prevent creating a redundant counter if a nested body ends with a ↵Igor Kudrin2016-08-291-0/+12
| | | | | | | | | | | | | | | | | 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
* [Coverage] Do not write out coverage mappings with zero entriesVedant Kumar2016-07-261-3/+6
| | | | | | | | | | | | | 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
* [Coverage] Attempt to appease a Windows builderVedant Kumar2016-07-221-1/+1
| | | | | | | | | | | | | | | | The builder prints out the following IR: \5CCoverageMapping\5COutput\5Ctest\5Cf1.c The updated test in r276367 expects path separators to be either '/' or '\\', so it chokes on the unexpected "5C" stuff. I'm not sure what that is, but I included a kludge that should work around it. Failing bot: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/8718 llvm-svn: 276370
* [Coverage] Strengthen a test caseVedant Kumar2016-07-221-4/+1
| | | | | | | | We should be able to use `mkdir` without turning on `REQUIRES: shell`. Moreover, this test should check for a path separator which precedes the relative filename to make sure that absolute paths are being used. llvm-svn: 276367
OpenPOWER on IntegriCloud