I happened to notice a memory leak and confirmed with valgrind:

65,640 (104 direct, 65,536 indirect) bytes in 1 blocks are definitely lost in 
loss record 530 of 532
   at 0x4844818: malloc (vg_replace_malloc.c:446)
   by 0x2C0DDBB: xmalloc (xmalloc.c:149)
   by 0xF22F49: new_graph(int) (graphds.cc:52)
   by 0x285F030: cfg_as_graph (path-coverage.cc:71)
   ...

Maybe amusingly, I specifically documented that cfg_as_graph have to
call free_graph on the returned pointer.

gcc/ChangeLog:

        * path-coverage.cc (find_prime_paths): Call free_graph.
---

Bootstrapped and tested on x86_64-linux-gnu, pushed as obvious.

---
 gcc/path-coverage.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/path-coverage.cc b/gcc/path-coverage.cc
index b9c25e3b3d92..6256e6cb8752 100644
--- a/gcc/path-coverage.cc
+++ b/gcc/path-coverage.cc
@@ -134,6 +134,7 @@ find_prime_paths (struct function *fn)
   if (any_empty)
     VEC_ORDERED_REMOVE_IF (paths, ix1, ix2, ptr, ptr->is_empty ());
 
+  free_graph (cfg);
   return paths;
 }
 
-- 
2.47.3

Reply via email to