[all-commits] [llvm/llvm-project] 57cb2f: Reland "[llvm-cov] Support multi-source object fil...

Yuhao Gu via All-commits all-commits at lists.llvm.org
Fri Aug 18 09:44:15 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 57cb2f6ffe63bbb1b753310aaa102614c00249ec
  Author: Yuhao Gu <yhgu2000 at outlook.com>
  Date:   2023-08-18 (Fri, 18 Aug 2023)

  Changed paths:
    M llvm/docs/CommandGuide/llvm-cov.rst
    M llvm/docs/CoverageMappingFormat.rst
    M llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
    M llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h
    M llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
    M llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
    M llvm/tools/llvm-cov/TestingSupport.cpp

  Log Message:
  Reland "[llvm-cov] Support multi-source object files for convert-for-testing"

`llvm-cov convert-for-testing` only functions properly when the input binary contains a single source file. When the binary has multiple source files, a `Malformed coverage data` error will occur when the generated .covmapping is read back. This is because the testing format lacks support for indicating the size of its file records, and current implementation just assumes there's only one record in it. This patch fixes this problem by introducing a new testing format version.

Changes to the code:

- Add a new format version. The version number is stored in the the last 8 bytes of the orignial magic number field to be backward-compatible.
- Output a LEB128 number before the file records section to indicate its size in the new version.
- Change the format parsing code correspondingly.
- Update the document to formalize the testing format.
- Additionally, fix the bug when converting COFF binaries.

Reviewed By: phosek, gulfem

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

More information about the All-commits mailing list