[all-commits] [llvm/llvm-project] b6b8fa: [llvm-cov][gcov] Support multi-files coverage in o...
int-zjt via All-commits
all-commits at lists.llvm.org
Fri Jun 20 01:24:40 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b6b8fa3b15d334c51fcf8763ccda0102a01aeb9c
https://github.com/llvm/llvm-project/commit/b6b8fa3b15d334c51fcf8763ccda0102a01aeb9c
Author: int-zjt <zhangjiatong.0 at bytedance.com>
Date: 2025-06-20 (Fri, 20 Jun 2025)
Changed paths:
A compiler-rt/test/profile/Posix/gcov-file-change-line.cpp
M compiler-rt/test/profile/Posix/gcov-file-change.cpp
M llvm/include/llvm/ProfileData/GCOV.h
M llvm/lib/ProfileData/GCOV.cpp
M llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
Log Message:
-----------
[llvm-cov][gcov] Support multi-files coverage in one basic block (#144504)
In the current gcov implementation, all lines within a basic block are
attributed to the source file of the block's containing function. This
is inaccurate when a block contains lines from other files (e.g., via
#include "foo.inc").
Commit
[406e81b](https://github.com/llvm/llvm-project/commit/406e81b79d26dae6838cc69d10a3e22635da09ef)
attempted to address this by filtering lines based on debug info types,
but this approach has two limitations:
* **Over-filtering**: Some valid lines belonging to the function are
incorrectly excluded.
* **Under-counting**: Lines not belonging to the function are filtered
out and omitted from coverage statistics.
**GCC Reference Behavior**
GCC's gcov implementation handles this case correctly.This change aligns
the LLVM behavior with GCC.
**Proposed Solution**
1. **GCNO Generation**:
* **Current**: Each block stores a single GCOVLines record (filename +
lines).
* **New**: Dynamically create new GCOVLines records whenever consecutive
lines in a block originate from different source files. Group subsequent
lines from the same file under one record.
2. **GCNO Parsing**:
* **Current**: Lines are directly attributed to the function's source
file.
* **New**: Introduce a GCOVLocation type to track filename/line mappings
within blocks. Statistics will reflect the actual source file for each
line.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list