6
6
// ld.lld: error: /lib/../lib64/Scrt1.o: ABI version 1 is not supported
7
7
// UNSUPPORTED: ppc && host-byteorder-big-endian
8
8
9
- // RUN: rm -rf %t && split-file %s %t && cd %t
9
+ // RUN: rm -rf %t && mkdir %t && split-file %s %t && cd %t
10
10
11
- // RUN: %clangxx_pgogen -fuse-ld=lld -O2 -fprofile-generate=. -mllvm -enable-vtable-value-profiling %s -o test
11
+ // RUN: %clangxx_pgogen -fuse-ld=lld -O2 -fprofile-generate=. -mllvm -enable-vtable-value-profiling lib.cpp main.cpp -o test
12
12
// RUN: env LLVM_PROFILE_FILE=test.profraw ./test
13
13
14
14
// Show vtable profiles from raw profile.
38
38
// COMMON-NEXT: Number of instrumented vtables: 2
39
39
// RAW: Indirect Target Results:
40
40
// RAW-NEXT: [ 0, _ZN8Derived14funcEii, 50 ] (25.00%)
41
- // RAW-NEXT: [ 0, {{.*}}instrprof-vtable-value-prof .cpp;_ZN12_GLOBAL__N_18Derived24funcEii, 150 ] (75.00%)
41
+ // RAW-NEXT: [ 0, {{.*}}lib .cpp;_ZN12_GLOBAL__N_18Derived24funcEii, 150 ] (75.00%)
42
42
// RAW-NEXT: [ 1, _ZN8Derived1D0Ev, 250 ] (25.00%)
43
- // RAW-NEXT: [ 1, {{.*}}instrprof-vtable-value-prof .cpp;_ZN12_GLOBAL__N_18Derived2D0Ev, 750 ] (75.00%)
43
+ // RAW-NEXT: [ 1, {{.*}}lib .cpp;_ZN12_GLOBAL__N_18Derived2D0Ev, 750 ] (75.00%)
44
44
// RAW-NEXT: VTable Results:
45
45
// RAW-NEXT: [ 0, _ZTV8Derived1, 50 ] (25.00%)
46
- // RAW-NEXT: [ 0, {{.*}}instrprof-vtable-value-prof .cpp;_ZTVN12_GLOBAL__N_18Derived2E, 150 ] (75.00%)
46
+ // RAW-NEXT: [ 0, {{.*}}lib .cpp;_ZTVN12_GLOBAL__N_18Derived2E, 150 ] (75.00%)
47
47
// RAW-NEXT: [ 1, _ZTV8Derived1, 250 ] (25.00%)
48
- // RAW-NEXT: [ 1, {{.*}}instrprof-vtable-value-prof .cpp;_ZTVN12_GLOBAL__N_18Derived2E, 750 ] (75.00%)
48
+ // RAW-NEXT: [ 1, {{.*}}lib .cpp;_ZTVN12_GLOBAL__N_18Derived2E, 750 ] (75.00%)
49
49
// INDEXED: Indirect Target Results:
50
- // INDEXED-NEXT: [ 0, {{.*}}instrprof-vtable-value-prof .cpp;_ZN12_GLOBAL__N_18Derived24funcEii, 150 ] (75.00%)
50
+ // INDEXED-NEXT: [ 0, {{.*}}lib .cpp;_ZN12_GLOBAL__N_18Derived24funcEii, 150 ] (75.00%)
51
51
// INDEXED-NEXT: [ 0, _ZN8Derived14funcEii, 50 ] (25.00%)
52
- // INDEXED-NEXT: [ 1, {{.*}}instrprof-vtable-value-prof .cpp;_ZN12_GLOBAL__N_18Derived2D0Ev, 750 ] (75.00%)
52
+ // INDEXED-NEXT: [ 1, {{.*}}lib .cpp;_ZN12_GLOBAL__N_18Derived2D0Ev, 750 ] (75.00%)
53
53
// INDEXED-NEXT: [ 1, _ZN8Derived1D0Ev, 250 ] (25.00%)
54
54
// INDEXED-NEXT: VTable Results:
55
- // INDEXED-NEXT: [ 0, {{.*}}instrprof-vtable-value-prof .cpp;_ZTVN12_GLOBAL__N_18Derived2E, 150 ] (75.00%)
55
+ // INDEXED-NEXT: [ 0, {{.*}}lib .cpp;_ZTVN12_GLOBAL__N_18Derived2E, 150 ] (75.00%)
56
56
// INDEXED-NEXT: [ 0, _ZTV8Derived1, 50 ] (25.00%)
57
- // INDEXED-NEXT: [ 1, {{.*}}instrprof-vtable-value-prof .cpp;_ZTVN12_GLOBAL__N_18Derived2E, 750 ] (75.00%)
57
+ // INDEXED-NEXT: [ 1, {{.*}}lib .cpp;_ZTVN12_GLOBAL__N_18Derived2E, 750 ] (75.00%)
58
58
// INDEXED-NEXT: [ 1, _ZTV8Derived1, 250 ] (25.00%)
59
59
// COMMON: Instrumentation level: IR entry_first = 0
60
60
// COMMON-NEXT: Functions shown: 1
94
94
// ICTEXT: # NumValueSites:
95
95
// ICTEXT: 2
96
96
// ICTEXT: 2
97
- // ICTEXT: {{.*}}instrprof-vtable-value-prof .cpp;_ZN12_GLOBAL__N_18Derived24funcEii:150
97
+ // ICTEXT: {{.*}}lib .cpp;_ZN12_GLOBAL__N_18Derived24funcEii:150
98
98
// ICTEXT: _ZN8Derived14funcEii:50
99
99
// ICTEXT: 2
100
- // ICTEXT: {{.*}}instrprof-vtable-value-prof .cpp;_ZN12_GLOBAL__N_18Derived2D0Ev:750
100
+ // ICTEXT: {{.*}}lib .cpp;_ZN12_GLOBAL__N_18Derived2D0Ev:750
101
101
// ICTEXT: _ZN8Derived1D0Ev:250
102
102
// ICTEXT: # ValueKind = IPVK_VTableTarget:
103
103
// ICTEXT: 2
104
104
// ICTEXT: # NumValueSites:
105
105
// ICTEXT: 2
106
106
// ICTEXT: 2
107
- // ICTEXT: {{.*}}instrprof-vtable-value-prof .cpp;_ZTVN12_GLOBAL__N_18Derived2E:150
107
+ // ICTEXT: {{.*}}lib .cpp;_ZTVN12_GLOBAL__N_18Derived2E:150
108
108
// ICTEXT: _ZTV8Derived1:50
109
109
// ICTEXT: 2
110
- // ICTEXT: {{.*}}instrprof-vtable-value-prof .cpp;_ZTVN12_GLOBAL__N_18Derived2E:750
110
+ // ICTEXT: {{.*}}lib .cpp;_ZTVN12_GLOBAL__N_18Derived2E:750
111
111
// ICTEXT: _ZTV8Derived1:250
112
112
113
113
// When vtable value profiles exist, pgo-instr-use pass should annotate them
114
114
// even if `-enable-vtable-value-profiling` is not explicitly on.
115
115
// RUN: %clangxx -m64 -fprofile-use=test.profdata -fuse-ld=lld -O2 \
116
116
// RUN: -mllvm -print-after=pgo-instr-use -mllvm -filter-print-funcs=main \
117
- // RUN: -mllvm -print-module-scope %s 2>&1 | FileCheck %s --check-prefix=ANNOTATE
117
+ // RUN: -mllvm -print-module-scope lib.cpp main.cpp 2>&1 | FileCheck %s --check-prefix=ANNOTATE
118
118
119
119
// ANNOTATE-NOT: Inconsistent number of value sites
120
120
// ANNOTATE: !{!"VP", i32 2
123
123
// if `-icp-max-num-vtables` is set to zero.
124
124
// RUN: %clangxx -m64 -fprofile-use=test.profdata -fuse-ld=lld -O2 \
125
125
// RUN: -mllvm -icp-max-num-vtables=0 -mllvm -print-after=pgo-instr-use \
126
- // RUN: -mllvm -filter-print-funcs=main -mllvm -print-module-scope %s 2>&1 | \
126
+ // RUN: -mllvm -filter-print-funcs=main -mllvm -print-module-scope lib.cpp main.cpp 2>&1 | \
127
127
// RUN: FileCheck %s --check-prefix=OMIT
128
128
129
129
// OMIT: Inconsistent number of value sites
145
145
// RUN: -Wl,-plugin-opt,-import-assume-unique-local \
146
146
// RUN: -Wl,-mllvm,-enable-vtable-profile-use -Rpass=pgo-icall-prom \
147
147
// RUN: -Wl,-mllvm,-print-after=pgo-icall-prom \
148
- // RUN: -Wl,-mllvm,-filter-print-funcs=main %s 2>&1 \
148
+ // RUN: -Wl,-mllvm,-filter-print-funcs=main lib.cpp main.cpp 2>&1 \
149
149
// RUN: | FileCheck %s --check-prefixes=REMARK,IR --implicit-check-not="!VP"
150
150
151
151
// For the indirect call site `ptr->func`
152
- // REMARK: instrprof-vtable-value-prof .cpp:240 :19: Promote indirect call to _ZN12_GLOBAL__N_18Derived24funcEii with count 150 out of 200, sink 1 instruction(s) and compare 1 vtable(s): {_ZTVN12_GLOBAL__N_18Derived2E}
153
- // REMARK: instrprof-vtable-value-prof .cpp:240 :19: Promote indirect call to _ZN8Derived14funcEii with count 50 out of 50, sink 1 instruction(s) and compare 1 vtable(s): {_ZTV8Derived1}
152
+ // REMARK: main .cpp:10 :19: Promote indirect call to _ZN12_GLOBAL__N_18Derived24funcEii.llvm.{{.*}} with count 150 out of 200, sink 1 instruction(s) and compare 1 vtable(s): {_ZTVN12_GLOBAL__N_18Derived2E.llvm.{{.*}} }
153
+ // REMARK: main .cpp:10 :19: Promote indirect call to _ZN8Derived14funcEii with count 50 out of 50, sink 1 instruction(s) and compare 1 vtable(s): {_ZTV8Derived1}
154
154
//
155
155
// For the indirect call site `delete ptr`
156
- // REMARK: instrprof-vtable-value-prof .cpp:242 :5: Promote indirect call to _ZN12_GLOBAL__N_18Derived2D0Ev with count 750 out of 1000, sink 2 instruction(s) and compare 1 vtable(s): {_ZTVN12_GLOBAL__N_18Derived2E}
157
- // REMARK: instrprof-vtable-value-prof .cpp:242 :5: Promote indirect call to _ZN8Derived1D0Ev with count 250 out of 250, sink 2 instruction(s) and compare 1 vtable(s): {_ZTV8Derived1}
156
+ // REMARK: main .cpp:12 :5: Promote indirect call to _ZN12_GLOBAL__N_18Derived2D0Ev.llvm.{{.*}} with count 750 out of 1000, sink 2 instruction(s) and compare 1 vtable(s): {_ZTVN12_GLOBAL__N_18Derived2E.llvm.{{.*}} }
157
+ // REMARK: main .cpp:12 :5: Promote indirect call to _ZN8Derived1D0Ev with count 250 out of 250, sink 2 instruction(s) and compare 1 vtable(s): {_ZTV8Derived1}
158
158
159
159
// The IR matchers for indirect callsite `ptr->func`.
160
160
// IR-LABEL: @main
161
161
// IR: [[OBJ:%.*]] = {{.*}}call {{.*}} @_Z10createTypei
162
162
// IR: [[VTABLE:%.*]] = load ptr, ptr [[OBJ]]
163
- // IR: [[CMP1:%.*]] = icmp eq ptr [[VTABLE]], getelementptr inbounds (i8, ptr @_ZTVN12_GLOBAL__N_18Derived2E, i32 16)
163
+ // IR: [[CMP1:%.*]] = icmp eq ptr [[VTABLE]], getelementptr inbounds (i8, ptr @_ZTVN12_GLOBAL__N_18Derived2E.llvm.{{.*}} , i32 16)
164
164
// IR: br i1 [[CMP1]], label %[[BB1:.*]], label %[[BB2:[a-zA-Z0-9_.]+]],
165
165
//
166
166
// IR: [[BB1]]:
167
- // IR: [[RESBB1:%.*]] = {{.*}}call {{.*}} @_ZN12_GLOBAL__N_18Derived24funcEii
167
+ // IR: [[RESBB1:%.*]] = {{.*}}call {{.*}} @_ZN12_GLOBAL__N_18Derived24funcEii.llvm.{{.*}}
168
168
// IR: br label %[[MERGE0:[a-zA-Z0-9_.]+]]
169
169
//
170
170
// IR: [[BB2]]:
@@ -203,23 +203,23 @@ class Derived1 : public Base {
203
203
204
204
~Derived1 () {}
205
205
};
206
+
207
+ __attribute__ ((noinline)) Base *createType(int a);
208
+
209
+ // --- lib.cpp
210
+ #include " lib.h"
211
+
206
212
namespace {
207
213
class Derived2 : public Base {
208
214
public:
209
- int func (int a, int b) override ;
215
+ int func (int a, int b) override { return a * (a - b); }
210
216
211
217
~Derived2 () {}
212
218
};
213
219
} // namespace
214
220
215
- __attribute__ ((noinline)) Base *createType(int a);
216
-
217
- // -- lib.cpp
218
-
219
221
int Derived1::func (int a, int b) { return a * b; }
220
222
221
- int Derived2::func (int a, int b) { return a * (a - b); }
222
-
223
223
Base *createType (int a) {
224
224
Base *base = nullptr ;
225
225
if (a % 4 == 0 )
@@ -230,6 +230,8 @@ Base *createType(int a) {
230
230
}
231
231
232
232
// --- main.cpp
233
+ #include " lib.h"
234
+
233
235
int main (int argc, char **argv) {
234
236
int sum = 0 ;
235
237
for (int i = 0 ; i < 1000 ; i++) {
0 commit comments