[all-commits] [llvm/llvm-project] f8ad86: [llvm-cov] Fix a bug about using `convert-for-test...

Yuhao Gu via All-commits all-commits at lists.llvm.org
Mon Aug 14 19:52:20 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f8ad86c23405168a8cd189590184fdcc296627e0
      https://github.com/llvm/llvm-project/commit/f8ad86c23405168a8cd189590184fdcc296627e0
  Author: Yuhao Gu <yhgu2000 at outlook.com>
  Date:   2023-08-15 (Tue, 15 Aug 2023)

  Changed paths:
    M llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
    M llvm/test/tools/llvm-cov/Inputs/combine_expansions.covmapping
    M llvm/test/tools/llvm-cov/Inputs/compilation_dir.covmapping
    M llvm/test/tools/llvm-cov/Inputs/coverage_prefix_map/main.covmapping
    M llvm/test/tools/llvm-cov/Inputs/deferred-regions.covmapping
    M llvm/test/tools/llvm-cov/Inputs/dir-with-filtering.covmapping
    M llvm/test/tools/llvm-cov/Inputs/double_dots.covmapping
    M llvm/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
    M llvm/test/tools/llvm-cov/Inputs/ifdef.covmapping
    M llvm/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
    M llvm/test/tools/llvm-cov/Inputs/malformedRegions.covmapping
    M llvm/test/tools/llvm-cov/Inputs/multiple-files.covmapping
    M llvm/test/tools/llvm-cov/Inputs/multiple-files2.covmapping
    M llvm/test/tools/llvm-cov/Inputs/multiple_objects/use_1.covmapping
    M llvm/test/tools/llvm-cov/Inputs/multiple_objects/use_2.covmapping
    M llvm/test/tools/llvm-cov/Inputs/multithreaded_report/main.covmapping
    M llvm/test/tools/llvm-cov/Inputs/name_allowlist.covmapping
    M llvm/test/tools/llvm-cov/Inputs/name_whitelist.covmapping
    M llvm/test/tools/llvm-cov/Inputs/native_separators.covmapping
    M llvm/test/tools/llvm-cov/Inputs/path_equivalence.covmapping
    M llvm/test/tools/llvm-cov/Inputs/prefer_used_to_unused.covmapping
    M llvm/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping
    M llvm/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
    M llvm/test/tools/llvm-cov/Inputs/relative_dir/main.covmapping
    M llvm/test/tools/llvm-cov/Inputs/report.covmapping
    M llvm/test/tools/llvm-cov/Inputs/showExpansions.covmapping
    M llvm/test/tools/llvm-cov/Inputs/showProjectSummary.covmapping
    M llvm/test/tools/llvm-cov/Inputs/showTabsHTML.covmapping
    M llvm/test/tools/llvm-cov/Inputs/sources_specified/main.covmapping
    M llvm/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
    M llvm/test/tools/llvm-cov/Inputs/zeroFunctionFile.covmapping
    M llvm/tools/llvm-cov/TestingSupport.cpp

  Log Message:
  -----------
  [llvm-cov] Fix a bug about using `convert-for-testing` on multi-source object files

`llvm-cov convert-for-testing` is used to build the .covmapping files used in its regression tests. However the current implementation only works when there's only one source file in the mapping information data. If there are more than 1 source files, `llvm-cov convert-for-testing` can still produce a .covmapping file, but when read it back, `llvm-cov` will report:

```
error: Failed to load coverage: 'main.covmapping': Malformed coverage data
```

This is because the output .covmapping file doesn't have any mark to indicate the boundary between file records and function records, and current implementation jsut assume there's only one file record in the .covmapping file.

Changes to the code:

- Make `llvm-cov convert-for-testing` output a LEB128 number before file records to indicate its size.
- Change the testing format parsing code correspondingly.
- Update existing .covmapping files.

Reviewed By: gulfem

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




More information about the All-commits mailing list