https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120938
Bug ID: 120938 Summary: discriminators are not useful in statements doing multiple calls Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- jh@shroud:~> cat d.C #include <stdio.h> volatile int a; static int dead () { return 0; } static void inc(int b) { a++; } static void inline_me (int l) { for (int i = 0; i < 100000000; i++) {dead();inc(dead ());inc(dead ());} if (!l) inline_me (l+1); printf ("block tail recursion\n"); } int main () { inline_me (0); return 0; } jh@shroud:~> cat afdo-test ~/trunk-install-new7/bin/gcc -O3 -g $* -o train -g -flto -fdump-tree-all-details-lineno || exit perf record -e ex_ret_brn_tkn:Pu -c100003 -b ./train || exit create_gcov --binary train --gcov_version 2 --use_discriminator_encoding --debug_dump perf.data --gcov a.gcov | tee gcov-debug ~/trunk-install-new7/bin/gcc -O3 -g -fauto-profile=a.gcov -Wauto-profile -fdump-tree-all-details-lineno -fdump-ipa-all-details -o trained $* || exit jh@shroud:~> sh afdo-test d.C gives d.C:16:14: warning: auto-profile contains inlined function with symbol name inc instead of symbol name _ZL4deadv [-Wauto-profile] 16 | {dead();inc(dead ());inc(dead ());} | ~~~~^~ d.C:13:1: warning: auto-profile of ‘void inline_me(int)’ contains extra callsites [-Wauto-profile] 13 | inline_me (int l) | ^~~~~~~~~ d.C:13:1: note: call of inc with relative location +3, discriminator 0 d.C:16:14: warning: auto-profile contains inlined function with symbol name inc instead of symbol name _ZL4deadv [-Wauto-profile] 16 | {dead();inc(dead ());inc(dead ());} | ~~~~^~ d.C:13:1: warning: auto-profile of ‘void inline_me(int)’ contains extra callsites [-Wauto-profile] 13 | inline_me (int l) | ^~~~~~~~~ d.C:13:1: note: call of inc with relative location +3, discriminator 0 The problem here is in the profile info: _ZL9inline_mei total:27945 head:0 1: 0 2.1: 9315 4: 0 6: 0 7: 0 3.2: inc total:9315 2: 9315 3.4: inc total:9315 2: 9315 5: inline_me total:0 2.1: 0 6: 0 3: inc total:0 2: 0 main total:18780 head:0 1: 0 4: 0 2: inline_me total:18780 2.1: 9390 5: 0 6: 0 3: inc total:9390 2: 9390 Notice that _ZL9inline_mei in offline version correctly records two calls of "inc" with discriminators 2 and 4. Inline versions in main and inline_me (which is dead) has only one call with discriminator 0 that gets confused with call to dead() function...