[PATCH 1/3] statistics: Fix --enable-gather-detailed-mem-stats for PCH [PR28734]
Lewis Hyatt <[email protected]> Sat, 1 Aug 2026 10:02:41 -0400
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
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.
---
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);
}