When using the -fbranch-probabilities switch to gcc, it reports a failure to find the required branch-probabilities file even if such a file exists all right. $ cat test.c #include <stdio.h> int main(int argc, char** argv) { int i; for (i = 0; i < argc; ++i) { printf("argv[%d] = \"%s\"\n", i, argv[i]); } return 0; } $ rm -f test.gcda $ gcc -o prof -fprofile-arcs test.c $ ./prof argv[0] = "./prof" $ test -f test.gcda && gcc -o final -fbranch-probabilities test.c test.c: In function ‘main’: test.c:9:1: note: file $PWD/test.gcda not found, execution counts assumed to be zero $ strace -efile -f gcc -o final -fbranch-probabilities test.c \ >/dev/null 2>&1 | grep gcda No output from strace, so it appears that gcc doesn't even try to open that file.
Not a problem with gcc 3.3.6-r1, 3.4.6-r2, 4.1.2 or 4.2.4-r1. At least none of them prints an warning. So I guess this is a regression in recent gcc. Identified the relevant command via strace and ran it through gdb: $ gdb --args /usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.2/cc1 -quiet test.c \ -D_FORTIFY_SOURCE=2 -quiet -dumpbase test.c -mtune=generic -march=x86-64 \ -auxbase test -fbranch-probabilities -o test.s It appears that coverage_init does not call read_counts_file because flag_profile_use is zero. So I assume that this problem was introduced by http://gcc.gnu.org/viewcvs/trunk/gcc/coverage.c?r1=133773&r2=133774
Created attachment 276363 [details, diff] Call read_counts_file unconditionally
Reproduced with USE=vanilla, filed report upstream: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49340
appears to work w/gcc-4.9.1