Re: [PATCH 1/3] statistics: Fix --enable-gather-detailed-mem-stats for PCH [PR28734]

Andrea Pinski <[email protected]> Sat, 1 Aug 2026 22:07:11 -0700
Newsgroups gmane.comp.gcc.patches
Message-ID <CALvbMcDgnZwjkNw-kb=DZS1sw7M8da4ocEzcEq2rZEh=O1NW3w@mail.gmail.com>
On Sat, Aug 1, 2026 at 7:04 AM Lewis Hyatt <[email protected]> wrote:
>
> When GCC is configured with --enable-gather-detailed-mem-stats, most of the
> pch.exp tests fail, because one function
> (mem_alloc_description::release_object_overhead) does not handle the case
> of being asked to process an unknown object. After PCH restore, there will
> be GGC'ed objects that the statistics gathering infrastructure does not know
> about, so simply ignore them in that case.
>
> gcc/ChangeLog:
>
>         PR middle-end/28374
>         * mem-stats.h (mem_alloc_description::release_object_overhead):
>         Handle the case that PTR was not found in the hash map, which can
>         happen after PCH restore.


Ok.

> ---
>  gcc/mem-stats.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h
> index ab8d5ca4e5a..2d4de15ccff 100644
> --- a/gcc/mem-stats.h
> +++ b/gcc/mem-stats.h
> @@ -535,6 +535,8 @@ inline void
>  mem_alloc_description<T>::release_object_overhead (void *ptr)
>  {
>    std::pair <T *, size_t> *entry = m_reverse_object_map->get (ptr);
> +  if (!entry)
> +    return;
>    entry->first->release_overhead (entry->second);
>    m_reverse_object_map->remove (ptr);
>  }