Files
clang-p2996/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test
Hongtao Yu 1662cfa4be [CSSPGO][CSProfileConverter] Remove call target samples when including callee samples into caller.
When a flat CS profile is converted to a nested profile, the call target samples for inlined callee contexts are left over in the callsite target map. This could cause indirect call promotion to function improperly. One issue is that the inlined callsites are treated with double amount of samples. The other is the inlined callsites are reconsidered for subsequent PGO ICP.

I'm fixing this by excluding call targets from the callsite for inlined targets. While fixing this I found that callsite target sum and the number of body samples for that callsite could be mismatched. {D122609} has an explanation and a fix for that on llvm-profgen side. For now I'm tolerating it in this change.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D125266
2022-05-13 09:19:32 -07:00

200 lines
8.9 KiB
Plaintext

RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample-preinline.proftext --gen-cs-nested-profile=1 -generate-merged-base-profiles=0
RUN: FileCheck %s < %t.proftext --match-full-lines --strict-whitespace
RUN: llvm-profdata merge --sample --text -output=%t.probe.proftext %S/Inputs/cs-sample-preinline-probe.proftext --gen-cs-nested-profile=1 -generate-merged-base-profiles=0
RUN: FileCheck %s < %t.probe.proftext --match-full-lines --strict-whitespace -check-prefix=PROBE
RUN: llvm-profdata merge --sample --extbinary -output=%t.profbin %S/Inputs/cs-sample-preinline.proftext --gen-cs-nested-profile=1 -generate-merged-base-profiles=0
RUN: llvm-profdata merge --sample --text -output=%t2.proftext %t.profbin
RUN: FileCheck %s < %t2.proftext --match-full-lines --strict-whitespace
RUN: llvm-profdata show --sample -show-sec-info-only %t.profbin | FileCheck %s -check-prefix=PREINLINE
RUN: llvm-profdata merge --sample --text -output=%t3.proftext %S/Inputs/cs-sample-preinline.proftext --gen-cs-nested-profile=1 -generate-merged-base-profiles=1
RUN: FileCheck %s < %t3.proftext --match-full-lines --strict-whitespace -check-prefix=RECOUNT
RUN: llvm-profdata merge --sample --extbinary -output=%t2.profbin %S/Inputs/cs-sample-preinline.proftext --gen-cs-nested-profile=1 -generate-merged-base-profiles=1
RUN: llvm-profdata show -sample -detailed-summary %S/Inputs/cs-sample-preinline.proftext | FileCheck %s -check-prefix=SUMMARY
RUN: llvm-profdata show -sample -detailed-summary %t2.profbin | FileCheck %s -check-prefix=SUMMARY-NEST
RUN: llvm-profdata show -sample -detailed-summary %t3.proftext | FileCheck %s -check-prefix=SUMMARY-NEST
; CHECK:main:1968621:12
; CHECK-NEXT: 2: 24
; CHECK-NEXT: 3: 17 _Z5funcAi:7
; CHECK-NEXT: 3.1: 10 _Z5funcBi:11
; CHECK-NEXT: 3: _Z5funcAi:1467388
; CHECK-NEXT: 0: 10
; CHECK-NEXT: 3: 24
; CHECK-NEXT: 1: _Z8funcLeafi:1467299
; CHECK-NEXT: 0: 6
; CHECK-NEXT: 1: 6
; CHECK-NEXT: 3: 287884
; CHECK-NEXT: 4: 287864 _Z3fibi:315608
; CHECK-NEXT: 15: 23
; CHECK-NEXT: !Attributes: 2
; CHECK-NEXT: !Attributes: 2
; CHECK-NEXT: 3.1: _Z5funcBi:500954
; CHECK-NEXT: 0: 19
; CHECK-NEXT: 3: 12
; CHECK-NEXT: 1: _Z8funcLeafi:500853
; CHECK-NEXT: 0: 15
; CHECK-NEXT: 1: 15
; CHECK-NEXT: 3: 74946
; CHECK-NEXT: 4: 74941 _Z3fibi:82359
; CHECK-NEXT: 10: 23324
; CHECK-NEXT: 11: 23327 _Z3fibi:25228
; CHECK-NEXT: 15: 11
; CHECK-NEXT: !Attributes: 2
; CHECK-NEXT: !Attributes: 2
; CHECK-NEXT:_Z5funcBi:240:13
; CHECK-NEXT: 0: 13
; CHECK-NEXT: 1: 13
; RECOUNT:main:1968621:12
; RECOUNT-NEXT: 2: 24
; RECOUNT-NEXT: 3: 17 _Z5funcAi:7
; RECOUNT-NEXT: 3.1: 10 _Z5funcBi:11
; RECOUNT-NEXT: 3: _Z5funcAi:1467388
; RECOUNT-NEXT: 0: 10
; RECOUNT-NEXT: 3: 24
; RECOUNT-NEXT: 1: _Z8funcLeafi:1467299
; RECOUNT-NEXT: 0: 6
; RECOUNT-NEXT: 1: 6
; RECOUNT-NEXT: 3: 287884
; RECOUNT-NEXT: 4: 287864 _Z3fibi:315608
; RECOUNT-NEXT: 15: 23
; RECOUNT-NEXT: !Attributes: 6
; RECOUNT-NEXT: !Attributes: 6
; RECOUNT-NEXT: 3.1: _Z5funcBi:500954
; RECOUNT-NEXT: 0: 19
; RECOUNT-NEXT: 3: 12
; RECOUNT-NEXT: 1: _Z8funcLeafi:500853
; RECOUNT-NEXT: 0: 15
; RECOUNT-NEXT: 1: 15
; RECOUNT-NEXT: 3: 74946
; RECOUNT-NEXT: 4: 74941 _Z3fibi:82359
; RECOUNT-NEXT: 10: 23324
; RECOUNT-NEXT: 11: 23327 _Z3fibi:25228
; RECOUNT-NEXT: 15: 11
; RECOUNT-NEXT: !Attributes: 6
; RECOUNT-NEXT: !Attributes: 6
; RECOUNT-NEXT:_Z8funcLeafi:1968152:31
; RECOUNT-NEXT: 0: 21
; RECOUNT-NEXT: 1: 21
; RECOUNT-NEXT: 3: 362830
; RECOUNT-NEXT: 4: 362805 _Z3fibi:397967
; RECOUNT-NEXT: 10: 23324
; RECOUNT-NEXT: 11: 23327 _Z3fibi:25228
; RECOUNT-NEXT: 15: 34
; RECOUNT-NEXT: !Attributes: 2
; RECOUNT-NEXT:_Z5funcAi:1467388:11
; RECOUNT-NEXT: 0: 10
; RECOUNT-NEXT: 3: 24
; RECOUNT-NEXT: 1: _Z8funcLeafi:1467299
; RECOUNT-NEXT: 0: 6
; RECOUNT-NEXT: 1: 6
; RECOUNT-NEXT: 3: 287884
; RECOUNT-NEXT: 4: 287864 _Z3fibi:315608
; RECOUNT-NEXT: 15: 23
; RECOUNT-NEXT: !Attributes: 6
; RECOUNT-NEXT: !Attributes: 2
; RECOUNT-NEXT:_Z5funcBi:501194:32
; RECOUNT-NEXT: 0: 32
; RECOUNT-NEXT: 1: 13
; RECOUNT-NEXT: 3: 12
; RECOUNT-NEXT: 1: _Z8funcLeafi:500853
; RECOUNT-NEXT: 0: 15
; RECOUNT-NEXT: 1: 15
; RECOUNT-NEXT: 3: 74946
; RECOUNT-NEXT: 4: 74941 _Z3fibi:82359
; RECOUNT-NEXT: 10: 23324
; RECOUNT-NEXT: 11: 23327 _Z3fibi:25228
; RECOUNT-NEXT: 15: 11
; RECOUNT-NEXT: !Attributes: 6
; PROBE:main:1968621:12
; PROBE-NEXT: 2: 24
; PROBE-NEXT: 3: 17 _Z5funcAi:7
; PROBE-NEXT: 3.1: 10 _Z5funcBi:11
; PROBE-NEXT: 3: _Z5funcAi:1467388
; PROBE-NEXT: 0: 10
; PROBE-NEXT: 3: 24
; PROBE-NEXT: 1: _Z8funcLeafi:1467299
; PROBE-NEXT: 0: 6
; PROBE-NEXT: 1: 6
; PROBE-NEXT: 3: 287884
; PROBE-NEXT: 4: 287864 _Z3fibi:315608
; PROBE-NEXT: 15: 23
; PROBE-NEXT: !CFGChecksum: 281479271677951
; PROBE-NEXT: !Attributes: 2
; PROBE-NEXT: !CFGChecksum: 844530426352218
; PROBE-NEXT: !Attributes: 2
; PROBE-NEXT: 3.1: _Z5funcBi:500954
; PROBE-NEXT: 0: 19
; PROBE-NEXT: 3: 12
; PROBE-NEXT: 1: _Z8funcLeafi:500853
; PROBE-NEXT: 0: 15
; PROBE-NEXT: 1: 15
; PROBE-NEXT: 3: 74946
; PROBE-NEXT: 4: 74941 _Z3fibi:82359
; PROBE-NEXT: 10: 23324
; PROBE-NEXT: 11: 23327 _Z3fibi:25228
; PROBE-NEXT: 15: 11
; PROBE-NEXT: !CFGChecksum: 281479271677951
; PROBE-NEXT: !Attributes: 2
; PROBE-NEXT: !CFGChecksum: 563022570642068
; PROBE-NEXT: !Attributes: 2
; PROBE-NEXT: !CFGChecksum: 563125815542069
; PROBE-NEXT:_Z5funcBi:240:13
; PROBE-NEXT: 0: 13
; PROBE-NEXT: 1: 13
; PROBE-NEXT: !CFGChecksum: 563022570642068
; PREINLINE: ProfileSummarySection {{.*}} Flags: {preInlined}
; SUMMARY: Total functions: 4
; SUMMARY-NEXT: Maximum function count: 32
; SUMMARY-NEXT: Maximum block count: 362830
; SUMMARY-NEXT: Total number of blocks: 16
; SUMMARY-NEXT: Total count: 772562
; SUMMARY-NEXT: Detailed summary:
; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 1 percentage of the total counts.
; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 10 percentage of the total counts.
; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 20 percentage of the total counts.
; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 30 percentage of the total counts.
; SUMMARY-NEXT: 1 blocks with count >= 362830 account for 40 percentage of the total counts.
; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 50 percentage of the total counts.
; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 60 percentage of the total counts.
; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 70 percentage of the total counts.
; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 80 percentage of the total counts.
; SUMMARY-NEXT: 2 blocks with count >= 362805 account for 90 percentage of the total counts.
; SUMMARY-NEXT: 3 blocks with count >= 23327 account for 95 percentage of the total counts.
; SUMMARY-NEXT: 4 blocks with count >= 23324 account for 99 percentage of the total counts.
; SUMMARY-NEXT: 4 blocks with count >= 23324 account for 99.9 percentage of the total counts.
; SUMMARY-NEXT: 11 blocks with count >= 24 account for 99.99 percentage of the total counts.
; SUMMARY-NEXT: 16 blocks with count >= 10 account for 99.999 percentage of the total counts.
; SUMMARY-NEXT: 16 blocks with count >= 10 account for 99.9999 percentage of the total counts.
; SUMMARY-NEST: Total functions: 4
; SUMMARY-NEST-NEXT: Maximum function count: 32
; SUMMARY-NEST-NEXT: Maximum block count: 362830
; SUMMARY-NEST-NEXT: Total number of blocks: 15
; SUMMARY-NEST-NEXT: Total count: 772504
; SUMMARY-NEST-NEXT: Detailed summary:
; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 1 percentage of the total counts.
; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 10 percentage of the total counts.
; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 20 percentage of the total counts.
; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 30 percentage of the total counts.
; SUMMARY-NEST-NEXT: 1 blocks with count >= 362830 account for 40 percentage of the total counts.
; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 50 percentage of the total counts.
; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 60 percentage of the total counts.
; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 70 percentage of the total counts.
; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 80 percentage of the total counts.
; SUMMARY-NEST-NEXT: 2 blocks with count >= 362805 account for 90 percentage of the total counts.
; SUMMARY-NEST-NEXT: 3 blocks with count >= 23327 account for 95 percentage of the total counts.
; SUMMARY-NEST-NEXT: 4 blocks with count >= 23324 account for 99 percentage of the total counts.
; SUMMARY-NEST-NEXT: 4 blocks with count >= 23324 account for 99.9 percentage of the total counts.
; SUMMARY-NEST-NEXT: 10 blocks with count >= 21 account for 99.99 percentage of the total counts.
; SUMMARY-NEST-NEXT: 15 blocks with count >= 10 account for 99.999 percentage of the total counts.
; SUMMARY-NEST-NEXT: 15 blocks with count >= 10 account for 99.9999 percentage of the total counts.