forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CSSPGO][llvm-profgen] Always report dangling probes for frames with …
…real samples. Report dangling probes for frames that have real samples collected. Dangling probes are the probes associated to an empty block. When reported, sample count on a dangling probe will not be trusted by the compiler and we will rely on the counts inference algorithm to get the probe a reasonable count. This actually fixes a bug where previously only those dangling probes with samples collected were reported. This patch also fixes two existing issues. Pseudo probes are stored in `Address2ProbesMap` and their pointers are used in `PseudoProbeInlineTree`. Previously `std::vector` was used to store probes and the pointers to probes may get obsolete as the vector grows. I'm changing `std::vector` to `std::list` instead. The other issue is that all outlined functions shared the same inline frame previously due to the unchanged `Index` value as the dummy inlineSite identifier. Good results seen for SPEC2017 in general regarding profile quality. Reviewed By: wenlei, wlei Differential Revision: https://reviews.llvm.org/D100235
- Loading branch information
Showing
7 changed files
with
107 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
llvm/test/tools/llvm-profgen/Inputs/inline-cs-dangling-pseudoprobe.perfscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PERF_RECORD_MMAP2 595196/595196: [0x201000(0x1000) @ 0 00:1d 224227621 1042948]: r-xp /home/inline-cs-pseudoprobe.perfbin | ||
|
||
20180e | ||
5541f689495641d7 | ||
0x201858/0x20180e/P/-/-/0 0x20182b/0x20184d/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 0x20182b/0x201800/P/-/-/0 |
51 changes: 51 additions & 0 deletions
51
llvm/test/tools/llvm-profgen/inline-cs-dangling-pseudoprobe.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
; RUN: llvm-profgen --perfscript=%S/Inputs/inline-cs-dangling-pseudoprobe.perfscript --binary=%S/Inputs/inline-cs-pseudoprobe.perfbin --output=%t --show-unwinder-output --csprof-cold-thres=0 | FileCheck %s --check-prefix=CHECK-UNWINDER | ||
; RUN: FileCheck %s --input-file %t | ||
|
||
; CHECK: [main:2 @ foo]:58:0 | ||
; CHECK-NEXT: 2: 15 | ||
; CHECK-NEXT: 3: 14 | ||
; CHECK-NEXT: 5: 14 | ||
; CHECK-NEXT: 6: 15 | ||
; CHECK-NEXT: !CFGChecksum: 138950591924 | ||
; CHECK:[main:2 @ foo:8 @ bar]:1:0 | ||
; CHECK-NEXT: 2: 18446744073709551615 | ||
; CHECK-NEXT: 3: 18446744073709551615 | ||
; CHECK-NEXT: 4: 1 | ||
; CHECK-NEXT: !CFGChecksum: 72617220756 | ||
|
||
|
||
; CHECK-UNWINDER: Binary(inline-cs-pseudoprobe.perfbin)'s Range Counter: | ||
; CHECK-UNWINDER-EMPTY: | ||
; CHECK-UNWINDER-NEXT: (800, 82b): 14 | ||
; CHECK-UNWINDER-NEXT: (84d, 858): 1 | ||
|
||
; CHECK-UNWINDER: Binary(inline-cs-pseudoprobe.perfbin)'s Branch Counter: | ||
; CHECK-UNWINDER-EMPTY: | ||
; CHECK-UNWINDER-NEXT: (82b, 800): 14 | ||
; CHECK-UNWINDER-NEXT: (82b, 84d): 1 | ||
; CHECK-UNWINDER-NEXT: (858, 80e): 1 | ||
|
||
; clang -O3 -fexperimental-new-pass-manager -fuse-ld=lld -fpseudo-probe-for-profiling | ||
; -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Xclang -mdisable-tail-calls | ||
; -g test.c -o a.out | ||
|
||
#include <stdio.h> | ||
|
||
int bar(int x, int y) { | ||
if (x % 3) { | ||
return x - y; | ||
} | ||
return x + y; | ||
} | ||
|
||
void foo() { | ||
int s, i = 0; | ||
while (i++ < 4000 * 4000) | ||
if (i % 91) s = bar(i, s); else s += 30; | ||
printf("sum is %d\n", s); | ||
} | ||
|
||
int main() { | ||
foo(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters