Fix typo and avoid possible memory leak in average_num_loop_insns

Function average_num_loop_insns forgets to free loop body in early
return.  Besides, overflow comparison checks 1000000 (e6) but the
return value is 100000 (e5), fix this typo.

gcc/ChangeLog

2020-01-14  Kewen Lin  <linkw@gcc.gnu.org>

    * cfgloopanal.c (average_num_loop_insns): Free bbs when early
    return, fix typo on return value.
This commit is contained in:
Kewen Lin 2020-01-14 02:34:10 -06:00
parent edabbec31e
commit b38e86ddb7
2 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2020-01-14 Kewen Lin <linkw@gcc.gnu.org>
* cfgloopanal.c (average_num_loop_insns): Free bbs when early return,
fix typo on return value.
2020-01-14 Xiong Hu Luo <luoxhu@linux.ibm.com>
PR ipa/69678

View File

@ -219,7 +219,10 @@ average_num_loop_insns (const class loop *loop)
ninsns += (sreal)binsns * bb->count.to_sreal_scale (loop->header->count);
/* Avoid overflows. */
if (ninsns > 1000000)
return 100000;
{
free (bbs);
return 1000000;
}
}
free (bbs);