Re: [PATCH v2 17/20] gcov: fix gcov_info_add() merge semantics for IOR counters

From: Peter Oberparleiter

Date: Thu Nov 05 2026 - 12:51:28 EST


On 03.11.2026 02:52, Sasha Levin wrote:
> gcov_info_add() unconditionally uses += to merge all counter types.
> This is wrong for counters that use IOR merge semantics (bitwise OR),
> such as GCOV_COUNTER_IOR and GCC 14's GCOV_COUNTER_CONDS (MC/DC
> condition coverage). These counters store bitsets that must be merged
> with |=, not accumulated with +=.
>
> Detect IOR merge semantics by comparing the merge function pointer
> against __gcov_merge_ior, matching how GCC's own libgcov identifies
> merge semantics. This fixes the pre-existing bug for GCOV_COUNTER_IOR
> and also enables correct merging for MC/DC condition coverage data.
>
> Fixes: 5f41ea0386a5 ("gcov: add support for gcc 4.7 gcov format")
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

Reviewed-by: Peter Oberparleiter <oberpar@xxxxxxxxxxxxx>


--
Peter Oberparleiter
Linux on IBM Z Development - IBM Germany R&D