Following simple example: #include <stdio.h>
static void a(void) { printf("a\n"); } static void b(void) { printf("b\n"); } static void __attribute__((noinline)) do_call(void (*p)(void)) { p(); } int main(void) { int i; for (i = 0; i < 30; i++) do_call((i%4) < 3 ? a : b); return 0; } I compile it with profile feedback and generate feedback data % gcc -O3 -fprofile-generate x.c % ./a.out ... output ... % gcc -O3 -fprofile-use x.c Examining the output do_call of the final code is just: 0000000000400520 <do_call>: 400520: ff e7 jmpq *%rdi But I would have expected the profile feedback code to detect that a is much more likely than b in the indirect call and inline a through devirtualization. -- Summary: devirtualization with profile feedback does not work for function pointers Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: andi-gcc at firstfloor dot org GCC host triplet: x86_64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45631