[gcc r17-2968] statistics: Fix --enable-gather-detailed-mem-stats for PCH [PR28734]
Lewis Hyatt via Gcc-cvs <[email protected]> Wed, 5 Aug 2026 01:45:54 +0000 (GMT)
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:60623805437fc74e8e0e90b92d86f181f5ab5ba2 commit r17-2968-g60623805437fc74e8e0e90b92d86f181f5ab5ba2 Author: Lewis Hyatt <[email protected]> Date: Sat Aug 1 09:52:31 2026 -0400 statistics: Fix --enable-gather-detailed-mem-stats for PCH [PR28734] 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/28734 * 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. Diff: --- gcc/mem-stats.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h index ab8d5ca4e5a8..2d4de15ccff9 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); }