From: Kewen Lin Date: Tue, 14 Jan 2020 08:34:10 +0000 (-0600) Subject: Fix typo and avoid possible memory leak in average_num_loop_insns X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b38e86ddb7a9b6d7e87d7cc0b23983d027fcbd96;p=gcc.git 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 * cfgloopanal.c (average_num_loop_insns): Free bbs when early return, fix typo on return value. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 07e5bebe909..f3301b16464 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2020-01-14 Kewen Lin + + * cfgloopanal.c (average_num_loop_insns): Free bbs when early return, + fix typo on return value. + 2020-01-14 Xiong Hu Luo PR ipa/69678 diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index 392b1c337c4..0b33e8272a7 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -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);