[PATCH] D157913: [Coverage] Allow Clang coverage to be used with debug info correlation.

Zequan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 14 12:36:46 PDT 2023


zequanwu updated this revision to Diff 556805.
zequanwu added a comment.

Remove profile name section.

Unused coverage function names are stored in debug info as a fake global variable info:

  0x0000000b: DW_TAG_compile_unit
  ...
  0x00000071:   DW_TAG_variable
                  DW_AT_name      ("__llvm_coverage_names")
                  DW_AT_type      (0x00000097 "Coverage Type")
                  DW_AT_location  (DW_OP_addr 0x0)
  
  0x00000084:     DW_TAG_LLVM_annotation
                    DW_AT_name    ("Cov Function Name")
                    DW_AT_const_value     ("bar")
  
  0x0000008d:     DW_TAG_LLVM_annotation
                    DW_AT_name    ("Cov Function Name")
                    DW_AT_const_value     ("baz")

llvm-cov will need to retrieve those names from the binary's debug info.

The reasons for not writing those names into the indexed profile file are following:

1. llvm-cov always need to read __llvm_covfun and __llvm_covmap from the unstripped binary, so it doesn't matter if those names are read from the binary or the indexed profile.
2. Since those names are just an array of strings, they don't have counter/data info. When llvm-profdata writes indexed profile, it iterates profile data to write records, so those unreferenced names are skipped even if I append them to the end of profile symtab. I'm not sure how we can simply append those names into the end of function name strings at indexed profile.

Overall, there are basically two types of function names:

1. Instrumented function names, which are stored in dwarf and later copied to indexed profile. llvm-cov reads them from indexed profile.
2. Unused function names(could be empty), which are stored in dwarf. llvm-cov reads them from the debug info.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157913/new/

https://reviews.llvm.org/D157913

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CodeGen/coverage-profile-raw-version.c
  compiler-rt/lib/profile/InstrProfilingWriter.c
  compiler-rt/test/profile/Darwin/coverage-debug-info-correlate.cpp
  compiler-rt/test/profile/Linux/coverage-debug-info-correlate.cpp
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/ProfileData/InstrProfCorrelator.h
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/InstrProfCorrelator.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-byte-coverage.ll
  llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-clang-coverage.ll
  llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-coverage.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157913.556805.patch
Type: text/x-patch
Size: 34933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230914/13a45978/attachment-0001.bin>


More information about the cfe-commits mailing list