Hi,

When a loop is vectorized, some statements are removed from the basic
blocks, but the vectorizer information attached to these BBs is never
freed.  This is because the attached information is freed by walking
the statements of the basic blocks: see tree-vectorizer.c:1750, but
the transformed code does not contain all the stmts of the original
code.  I can't find out a good solution for tracking these stmts, but
one solution could be to free the stmt_info when the stmts are removed
from a BB.

For all the testcases of the vectorizer you should see more or less
memory leaking like this:

valgrind --leak-check=full ./cc1 -O3 vect-1.c

==16863== 1,064 bytes in 33 blocks are definitely lost in loss record 2 of 7
==16863==    at 0x401D38B: malloc (vg_replace_malloc.c:149)
==16863==    by 0x8A3631C: xrealloc (xmalloc.c:177)
==16863==    by 0x87497D1: vec_heap_o_reserve_1 (vec.c:176)
==16863==    by 0x8749859: vec_heap_p_reserve_exact (vec.c:200)
==16863==    by 0x86B9263: VEC_dr_p_heap_alloc (tree-vectorizer.h:333)
==16863==    by 0x86B90DA: new_stmt_vec_info (tree-vectorizer.c:1545)
==16863==    by 0x86B94D8: new_loop_vec_info (tree-vectorizer.c:1632)
==16863==    by 0x86932BB: vect_analyze_loop_form (tree-vect-analyze.c:4218)
==16863==    by 0x869347D: vect_analyze_loop (tree-vect-analyze.c:4259)
==16863==    by 0x86BCFDE: vectorize_loops (tree-vectorizer.c:2685)
==16863==    by 0x8606277: tree_vectorize (tree-ssa-loop.c:216)
==16863==    by 0x83DB9F9: execute_one_pass (passes.c:1118)

Sebastian

Reply via email to