Bug 18152

Summary: corrupted profile info after optimized compilation and --fprofile-use
Product: gcc Reporter: joc
Component: gcov-profileAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED INVALID    
Severity: normal CC: gcc-bugs
Priority: P2    
Version: 3.4.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: c/h files and gcda file to reproduce -fprofile-use bug

Description joc 2004-10-25 21:49:46 UTC
Hi,

When trying to compile a file compiled with optimized flag, I got the following
error :


gcc -DHAVE_CONFIG_H -I.    -O3 -DDBUG_OFF -Wimplicit -Wreturn-type -Wswitch
-Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare
-Wwrite-strings -Wunused -mtune=athlon-mp -march=athlon-mp -mfpmath=sse -mmmx
-msse -m3dnow -O3 -fomit-frame-pointer -fmove-all-movables -freduce-all-givs
-frename-registers -fprofile-use -fbranch-target-load-optimize2   -MT
ctype-latin1.o -MD -MP -MF ".deps/ctype-latin1.Tpo" -c -o ctype-latin1.o
ctype-latin1.c;
ctype-latin1.c: In function `my_mb_wc_latin1':
ctype-latin1.c:363: error: corrupted profile info: number of executions for edge
3-4 thought to be 13
ctype-latin1.c:363: error: corrupted profile info: number of executions for edge
3-5 thought to be -12

However if I compile the file without the -O3 flag, it only issues warning :

gcc -DHAVE_CONFIG_H -I.    -DDBUG_OFF -Wimplicit -Wreturn-type -Wswitch
-Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare
-Wwrite-strings -Wunused -mtune=athlon-mp -march=athlon-mp -mfpmath=sse -mmmx
-msse -m3dnow -fomit-frame-pointer -fmove-all-movables -freduce-all-givs
-frename-registers -fprofile-use -fbranch-target-load-optimize2   -MT
ctype-latin1.o -MD -MP -MF ".deps/ctype-latin1.Tpo" -c -o ctype-latin1.o
ctype-latin1.c;    
ctype-latin1.c: In function `my_mb_wc_latin1':
ctype-latin1.c:363: warning: no coverage for function 'my_mb_wc_latin1' found.
ctype-latin1.c: In function `my_wc_mb_latin1':
ctype-latin1.c:379: warning: no coverage for function 'my_wc_mb_latin1' found.
ctype-latin1.c: In function `my_strnncoll_latin1_de':
ctype-latin1.c:570: warning: no coverage for function 'my_strnncoll_latin1_de'
found.
ctype-latin1.c: In function `my_strnncollsp_latin1_de':
ctype-latin1.c:633: warning: no coverage for function 'my_strnncollsp_latin1_de'
found.
ctype-latin1.c: In function `my_strnxfrm_latin1_de':
ctype-latin1.c:651: warning: no coverage for function 'my_strnxfrm_latin1_de' found.
ctype-latin1.c: In function `my_hash_sort_latin1_de':
ctype-latin1.c:677: warning: no coverage for function 'my_hash_sort_latin1_de'
found.

So it seems something is wrong with profile-generate / profile-use in this case.

I'm uploading the c, gcda and h files to reproduce the problem with profile-use.

Thanks,
  Jocelyn
Comment 1 Andrew Pinski 2004-10-25 21:52:14 UTC
How did you compile the one which you are profiling?
Comment 2 joc 2004-10-25 21:53:32 UTC
Created attachment 7409 [details]
c/h files and gcda file to reproduce -fprofile-use bug
Comment 3 joc 2004-10-25 21:56:43 UTC
The file has been compiled with 

gcc -DHAVE_CONFIG_H -I. -O3 -DDBUG_OFF -Wimplicit -Wreturn-type -Wswitch
-Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare
-Wwrite-strings -Wunused -mtune=athlon-mp -march=athlon-mp -mfpmath=sse -mmmx
-msse -m3dnow -O3 -fomit-frame-pointer -fmove-all-movables -freduce-all-givs
-frename-registers -fprofile-generate -fbranch-target-load-optimize2   -MT
ctype-latin1.o -MD -MP -MF ".deps/ctype-latin1.Tpo" -c -o ctype-latin1.o
ctype-latin1.c

command line
Comment 4 joc 2004-10-25 22:03:47 UTC
Note also that occurs when trying to compile MySQL with -fprofile-use flag, and
several other files are affected by the problem (but now all the files).

For example, an other error during compilation :

[root@forumsql] /usr/local/mysql-4.1/innobase/page> gcc -DHAVE_CONFIG_H -I. -I.
-I.. -I./../include -I./../../include -I../../include    -DDBUG_OFF -O3
-DDBUG_OFF -mtune=athlon-mp -march=athlon-mp -fprofile-use -DDEBUG_OFF
-DUNIV_LINUX -DUNIV_INTEL_X86 -MT page0page.o -MD -MP -MF ".deps/page0page.Tpo"
-c -o page0page.o page0page.c; 
page0page.c: In function `page_rec_get_n_recs_before':
page0page.c:1112: error: corrupted profile info: number of executions for edge
1-2 thought to be -1
page0page.c:1112: error: corrupted profile info: number of executions for edge
1-11 thought to be 1497932
page0page.c:1112: error: corrupted profile info: number of iterations for basic
block 2 thought to be -1
page0page.c:1112: error: corrupted profile info: number of executions for edge
16-17 thought to be -3
page0page.c:1112: error: corrupted profile info: number of executions for edge
16-26 thought to be 107993545

When removing the -mtune / -march flags :

[root@forumsql] /usr/local/mysql-4.1/innobase/page> gcc -DHAVE_CONFIG_H -I. -I.
-I.. -I./../include -I./../../include -I../../include    -DDBUG_OFF -O3
-DDBUG_OFF  -fprofile-use -DDEBUG_OFF -DUNIV_LINUX -DUNIV_INTEL_X86 -MT
page0page.o -MD -MP -MF ".deps/page0page.Tpo" -c -o page0page.o page0page.c;
page0page.c: In function `page_delete_rec_list_end':
page0page.c:700: error: coverage mismatch for function
'page_delete_rec_list_end' while reading counter 'arcs'.
page0page.c:700: error: number of counters is 250 instead of 251

When removing the -O3 flag, a lot of "warning: no coverage for function
'function_name' found", but no more compilation errors.
Comment 5 joc 2005-04-05 19:44:12 UTC
Any news about this issue ?

Thanks !
  Jocelyn
Comment 6 Steven Bosscher 2005-07-14 09:32:05 UTC
We need a self-contained test case.  You have not provided that, so now we 
cannot reproduce the bug. 
 
Please read http://gcc.gnu.org/bugs.html. 
 
In this case, I get lots of missing symbols errors at link time: 
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.4/../../../../lib/crt1.o(.text+0x18): 
In function `_start': 
../sysdeps/i386/elf/start.S:115: undefined reference to `main' 
/tmp/ccuZB30b.o(.data+0xf28): undefined reference to `my_mbcharlen_8bit' 
/tmp/ccuZB30b.o(.data+0xf2c): undefined reference to `my_numchars_8bit' 
/tmp/ccuZB30b.o(.data+0xf30): undefined reference to `my_charpos_8bit' 
/tmp/ccuZB30b.o(.data+0xf34): undefined reference to `my_well_formed_len_8bit' 
/tmp/ccuZB30b.o(.data+0xf38): undefined reference to `my_lengthsp_8bit' 
/tmp/ccuZB30b.o(.data+0xf3c): undefined reference to `my_numcells_8bit' 
(etc.) 
 
So I can't reproduce your problem. 
 
 
Comment 7 Andrew Pinski 2005-10-04 13:25:04 UTC
No feedback in 3 month (T-10 days).