File tree 3 files changed +93
-0
lines changed
3 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 22
22
#include " llvm/ADT/iterator_range.h"
23
23
#include " llvm/IR/Constants.h"
24
24
#include " llvm/IR/Metadata.h"
25
+ #include " llvm/IR/PseudoProbe.h"
25
26
#include " llvm/Support/Casting.h"
26
27
#include " llvm/Support/CommandLine.h"
27
28
#include " llvm/Support/Discriminator.h"
@@ -2075,6 +2076,14 @@ class DILocation : public MDNode {
2075
2076
static unsigned
2076
2077
getBaseDiscriminatorFromDiscriminator (unsigned D,
2077
2078
bool IsFSDiscriminator = false ) {
2079
+ // Return the probe id instead of zero for a pseudo probe discriminator.
2080
+ // This should help differenciate callsites with same line numbers to
2081
+ // achieve a decent AutoFDO profile under -fpseudo-probe-for-profiling,
2082
+ // where the original callsite dwarf discriminator is overwritten by
2083
+ // callsite probe information.
2084
+ if (isPseudoProbeDiscriminator (D))
2085
+ return PseudoProbeDwarfDiscriminator::extractProbeIndex (D);
2086
+
2078
2087
if (IsFSDiscriminator)
2079
2088
return getMaskedDiscriminator (D, getBaseDiscriminatorBits ());
2080
2089
return getUnsignedFromPrefixEncoding (D);
Original file line number Diff line number Diff line change @@ -106,6 +106,8 @@ if.end:
106
106
;YAML-NEXT: - Line: '1'
107
107
;YAML-NEXT: - String: ':'
108
108
;YAML-NEXT: - Column: '11'
109
+ ;YAML-NEXT: - String: .
110
+ ;YAML-NEXT: - Disc: '2'
109
111
;YAML-NEXT: - String: ';'
110
112
;YAML-NEXT: ...
111
113
;YAML: --- !Analysis
Original file line number Diff line number Diff line change
1
+ ; RUN: llvm-profgen --format=text --use-dwarf-correlation --ignore-stack-samples --perfscript=%S/Inputs/cs-preinline-cost.perfscript --binary=%S/Inputs/cs-preinline-cost.perfbin --output %t
2
+ ; RUN: FileCheck %s --input-file %t
3
+
4
+ ; CHECK: main:947937:0
5
+ ; CHECK-NEXT: 2: 545
6
+ ; CHECK-NEXT: 3: 545
7
+ ; CHECK-NEXT: 5: 545
8
+ ; CHECK-NEXT: 7: 0
9
+ ; CHECK-NEXT: 65496: 545
10
+ ; CHECK-NEXT: 3.7: _Z3fooi:915794
11
+ ; CHECK-NEXT: 1: 545
12
+ ; CHECK-NEXT: 5: 545
13
+ ; CHECK-NEXT: 6: 272
14
+ ; CHECK-NEXT: 10: 273
15
+ ; CHECK-NEXT: 11: 180
16
+ ; CHECK-NEXT: 12: 6965
17
+ ; CHECK-NEXT: 13: 6965
18
+ ; CHECK-NEXT: 14: 6965
19
+ ; CHECK-NEXT: 15: 6965
20
+ ; CHECK-NEXT: 20: 182
21
+ ; CHECK-NEXT: 21: 6958
22
+ ; CHECK-NEXT: 22: 6958
23
+ ; CHECK-NEXT: 23: 6958
24
+ ; CHECK-NEXT: 24: 6958
25
+ ; CHECK-NEXT: 29: 272
26
+ ; CHECK-NEXT: 65529: 182
27
+ ; CHECK-NEXT: 4.8: _Z3fooi:16338
28
+ ; CHECK-NEXT: 1: 272
29
+ ; CHECK-NEXT: 6: 545
30
+
31
+
32
+
33
+
34
+ ; binary is built with the source below using the following command line:
35
+ ; clang -O3 -g -fpseudo-probe-for-profiling test.cpp
36
+ ;
37
+ ;#include <stdio.h>
38
+ ;
39
+ ;volatile int state = 9000;
40
+ ;
41
+ ;int foo(int x) {
42
+ ; if (x == 0) {
43
+ ; return 7;
44
+ ; }
45
+ ;
46
+ ; if ((x & 1) == 0) {
47
+ ; state--;
48
+ ; return 9;
49
+ ; }
50
+ ;
51
+ ; if (state > 5000) {
52
+ ; while (state > 5000) {
53
+ ; for (int i = 50; i >= 0; i--) {
54
+ ; state *= 6;
55
+ ; state /= 7;
56
+ ; state -= 1;
57
+ ; }
58
+ ; }
59
+ ; }
60
+ ; else {
61
+ ; while (state < 5000) {
62
+ ; for (int i = 50; i >= 0; i--) {
63
+ ; state *= 6;
64
+ ; state /= 5;
65
+ ; state += 1;
66
+ ; }
67
+ ; }
68
+ ; }
69
+ ;
70
+ ; return state;
71
+ ;}
72
+ ;
73
+ ;volatile int cnt = 10000000;//10000000;
74
+ ;int main() {
75
+ ; int r = 0;
76
+ ; for (int i = 0; i < cnt; i++) {
77
+ ; r += foo(i);
78
+ ; r -= foo(i & (~1));
79
+ ; r += foo(0);
80
+ ; }
81
+ ; return r;
82
+ ;}
You can’t perform that action at this time.
0 commit comments