[Bug gcov-profile/90420] [GCOV] wrong coverage with "-O3" or "-O2" optimizations for function call

yangyibiao at nju dot edu.cn gcc-bugzilla@gcc.gnu.org
Fri May 10 06:24:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90420

--- Comment #2 from Yibiao Yang <yangyibiao at nju dot edu.cn> ---
(In reply to Martin Liška from comment #1)
> > $ gcc -O3 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
> > File 'small.c'
> > Lines executed:78.57% of 14
> > Creating 'small.c.gcov'
> > 
> >         -:    0:Source:small.c
> >         -:    0:Graph:small.gcno
> >         -:    0:Data:small.gcda
> >         -:    0:Runs:1
> >         -:    1:#define N 1000
> >         -:    2:
> >         -:    3:int argc = 1;
> >         -:    4:
> >     #####:    5:int func (int *p, int *q) {
> >     1001*:    6:  int x = 0;
> >     #####:    7:  for (int i = 0; i < N; i++) { 
> >     1000*:    8:    x += (q[i] + p[i]);
> >         -:    9:  }
> >        1*:   10:  return x;
> >         -:   11:}
> >         -:   12:
> >         1:   13:int main ()
> >         -:   14:{
> >         1:   15:  int x = 0;
> >         1:   16:  int A1[N], A2[N];
> >         -:   17:
> >      1001:   18:  for (int i = 0; i < N; i++) {
> >      1000:   19:    A1[i] = 5 + argc;
> >      1000:   20:    A2[i] = 1;
> >         -:   21:  }
> >         -:   22:  
> >      1001:   23:  x = func (A1, A2);
> >         -:   24:
> >         1:   25:  if (x != N * 7)
> >     #####:   26:    return 1;
> >         -:   27:
> >         -:   28:  return 0;
> >         -:   29:}
> > 
> > 
> > When using "-O3" optimization, Line #6 and Line #22 are wrongly marked as
> 
> I can't see Line #22 being executed.
> 
Sorry. It should be Line #23


More information about the Gcc-bugs mailing list