Hi,
I ran into this memory leak issue in tree-predcom.c when investigating other 
PRs.
This is the obvious fix by freeing reference of trivial component.
Bootstrap and test on x86_64.  Is it OK?

Thanks,
bin
2017-11-02  Bin Cheng  <bin.ch...@arm.com>

        * tree-predcom.c (determine_roots_comp): Avoid memory leak by freeing
        reference of trivial component.
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index a243bce..e493dcd 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1341,7 +1341,14 @@ determine_roots_comp (struct loop *loop,
 
   /* Trivial component.  */
   if (comp->refs.length () <= 1)
-    return;
+    {
+      if (comp->refs.length () == 1)
+       {
+         free (comp->refs[0]);
+         comp->refs.truncate (0);
+       }
+      return;
+    }
 
   comp->refs.qsort (order_drefs);
   FOR_EACH_VEC_ELT (comp->refs, i, a)

Reply via email to