Message ID | 151be804-be3a-c310-cb61-81289ea3efae@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | Fix typo and avoid possible memory leak | expand |
"Kewen.Lin" <linkw@linux.ibm.com> writes: > Hi, > > 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), I guess it's unexpected, a typo? > > Bootstrapped and regress tested on powerpc64le-linux-gnu. > I guess this should go to GCC11? Is it ok? OK for GCC 10, thanks. This is a regression from GCC 7. Richard > > BR, > Kewen > > gcc/ChangeLog > > 2020-01-13 Kewen Lin <linkw@gcc.gnu.org> > > * cfgloopanal.c (average_num_loop_insns): Free bbs when early return, > fix typo on return value. > > -------- > > diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c > index 199c20b..65d239a 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);
on 2020/1/13 下午6:46, Richard Sandiford wrote: > "Kewen.Lin" <linkw@linux.ibm.com> writes: >> Hi, >> >> 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), I guess it's unexpected, a typo? >> >> Bootstrapped and regress tested on powerpc64le-linux-gnu. >> I guess this should go to GCC11? Is it ok? > > OK for GCC 10, thanks. This is a regression from GCC 7. > Hi Richard, Thanks for correcting me it's a regression! Committed in b38e86ddb7a9. BR, Kewen
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index 199c20b..65d239a 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);