1- ## Check that BOLT handles correctly folding functions with --icf- safe that can be referenced.
2- # The compare is generated by the ICP path with instrumentation profiling.
1+ ## Check that BOLT handles correctly folding functions with --icf= safe that can be referenced.
2+ ## The compare is generated by the ICP path with instrumentation profiling.
33
44# REQUIRES: system-linux
55# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o
1818# SAFEICFCHECK-NEXT: ===---------
1919
2020
21- # generate profile
22- # clang++ -O2 -fprofile-generate=. main.cpp -c -o mainProf.o
23- # PROF=test.profdata
24- # clang++ -m64 -fprofile-use=$PROF \
25- # -mllvm -disable-icp=true -mllvm -print-after-all \
26- # -g0 -flto=thin -fwhole-program-vtables -fno-split-lto-unit -O2 \
27- # -fdebug-types-section \
28- # main.cpp -c -o mainProfLTO.bc
29- # PASS='pgo-icall-prom'
30- # clang++ -m64 -fprofile-use=$PROF \
31- # -O3 -Rpass=$PASS \
32- # -mllvm -print-before=$PASS \
33- # -mllvm -print-after=$PASS \
34- # -mllvm -filter-print-funcs=main \
35- # -mllvm -debug-only=$PASS \
36- # -x ir \
37- # mainProfLTO.bc -c -o mainProfFinal.o
21+ ## generate profile
22+ ## clang++ -O2 -fprofile-generate=. main.cpp -c -o mainProf.o
23+ ## PROF=test.profdata
24+ ## clang++ -m64 -fprofile-use=$PROF \
25+ ## -mllvm -disable-icp=true -mllvm -print-after-all \
26+ ## -g0 -flto=thin -fwhole-program-vtables -fno-split-lto-unit -O2 \
27+ ## -fdebug-types-section \
28+ ## main.cpp -c -o mainProfLTO.bc
29+ ## PASS='pgo-icall-prom'
30+ ## clang++ -m64 -fprofile-use=$PROF \
31+ ## -O3 -Rpass=$PASS \
32+ ## -mllvm -print-before=$PASS \
33+ ## -mllvm -print-after=$PASS \
34+ ## -mllvm -filter-print-funcs=main \
35+ ## -mllvm -debug-only=$PASS \
36+ ## -x ir \
37+ ## mainProfLTO.bc -c -o mainProfFinal.o
3838
39- # class Base {
40- # public:
41- # virtual int func(int a, int b) const = 0;
42- #
43- # virtual ~Base() {};
44- # };
45- #
46- # //namespace {
47- # class Derived2 : public Base {
48- # int c = 5;
49- # public:
50- # __attribute__((noinline)) int func(int a, int b)const override { return a * (a - b) + this->c; }
51- #
52- # ~Derived2() {}
53- # };
54- #
55- # class Derived3 : public Base {
56- # int c = 500;
57- # public:
58- # __attribute__((noinline)) int func(int a, int b) const override { return a * (a - b) + this->c; }
59- # ~Derived3() {}
60- # };
61- # //} // namespace//
62- #
63- # __attribute__((noinline)) Base *createType(int a) {
64- # Base *base = nullptr;
65- # if (a == 4)
66- # base = new Derived2();
67- # else
68- # base = new Derived3();
69- # return base;
70- # }
71- #
72- # extern int returnFive();
73- # extern int returnFourOrFive(int val);
74- # int main(int argc, char **argv) {
75- # int sum = 0;
76- # int a = returnFourOrFive(argc);
77- # int b = returnFive();
78- # Base *ptr = createType(a);
79- # Base *ptr2 = createType(b);
80- # sum += ptr->func(b, a) + ptr2->func(b, a);
81- # return 0;
82- # }
83- # clang++ -c helper.cpp -o helper.o
84- # int FooVar = 1;
85- # int BarVar = 2;
86- #
87- # int fooGlobalFuncHelper(int a, int b) {
88- # return 5;
89- # }
90- # Manually modified to remove "extra" assembly.
39+ ## class Base {
40+ ## public:
41+ ## virtual int func(int a, int b) const = 0;
42+ ##
43+ ## virtual ~Base() {};
44+ ## };
45+ ##
46+ ## //namespace {
47+ ## class Derived2 : public Base {
48+ ## int c = 5;
49+ ## public:
50+ ## __attribute__((noinline)) int func(int a, int b)const override { return a * (a - b) + this->c; }
51+ ##
52+ ## ~Derived2() {}
53+ ## };
54+ ##
55+ ## class Derived3 : public Base {
56+ ## int c = 500;
57+ ## public:
58+ ## __attribute__((noinline)) int func(int a, int b) const override { return a * (a - b) + this->c; }
59+ ## ~Derived3() {}
60+ ## };
61+ ## //} // namespace//
62+ ##
63+ ## __attribute__((noinline)) Base *createType(int a) {
64+ ## Base *base = nullptr;
65+ ## if (a == 4)
66+ ## base = new Derived2();
67+ ## else
68+ ## base = new Derived3();
69+ ## return base;
70+ ## }
71+ ##
72+ ## extern int returnFive();
73+ ## extern int returnFourOrFive(int val);
74+ ## int main(int argc, char **argv) {
75+ ## int sum = 0;
76+ ## int a = returnFourOrFive(argc);
77+ ## int b = returnFive();
78+ ## Base *ptr = createType(a);
79+ ## Base *ptr2 = createType(b);
80+ ## sum += ptr->func(b, a) + ptr2->func(b, a);
81+ ## return 0;
82+ ## }
83+ ## clang++ -c helper.cpp -o helper.o
84+ ## int FooVar = 1;
85+ ## int BarVar = 2;
86+ ##
87+ ## int fooGlobalFuncHelper(int a, int b) {
88+ ## return 5;
89+ ## }
90+ ## Manually modified to remove "extra" assembly.
9191 .section .text.hot.,"ax",@progbits
9292 .globl _Z10createTypei
93- .p2align 4, 0x90
9493 .type _Z10createTypei,@function
9594_Z10createTypei:
9695 .cfi_startproc
@@ -99,41 +98,33 @@ _Z10createTypei:
9998 leaq _ZTV8Derived3+16(%rip), %rdx
10099 cmoveq %rcx, %rdx
101100 retq
102- .Lfunc_end0:
103- .size _Z10createTypei, .Lfunc_end0-_Z10createTypei
101+ .size _Z10createTypei, .-_Z10createTypei
104102 .cfi_endproc
105103
106104
107105 .globl _Z10returnFivev
108- .p2align 4, 0x90
109106 .type _Z10returnFivev,@function
110107_Z10returnFivev:
111108 .cfi_startproc
112- # %bb.0:
113109 movl $5, %eax
114110 retq
115- .Lfunc_end01:
116- .size _Z10returnFivev, .Lfunc_end01-_Z10returnFivev
111+ .size _Z10returnFivev, .-_Z10returnFivev
117112 .cfi_endproc
118113
119114 .globl returnFourOrFiveFunc
120- .p2align 4, 0x90
121115 .type returnFourOrFiveFunc,@function
122116returnFourOrFiveFunc:
123117 .cfi_startproc
124- # %bb.0:
125118 xorl %eax, %eax
126119 cmpl $1, %edi
127120 sete %al
128121 xorl $5, %eax
129122 retq
130- .Lfunc_end11:
131- .size returnFourOrFiveFunc, .Lfunc_end11-returnFourOrFiveFunc
123+ .size returnFourOrFiveFunc, .-returnFourOrFiveFunc
132124 .cfi_endproc
133125
134126
135127 .globl main
136- .p2align 4, 0x90
137128 .type main,@function
138129main:
139130 .cfi_startproc
@@ -142,88 +133,64 @@ main:
142133 callq _Z10createTypei
143134 callq _Z10createTypei
144135 leaq _ZNK8Derived24funcEii(%rip), %rcx
145- jne .LBB1_2
146136 callq _ZNK8Derived24funcEii
147- .LBB1_3:
148137 leaq _ZNK8Derived34funcEii(%rip), %rcx
149- jne .LBB1_5
150138 callq _ZNK8Derived34funcEii
151- .LBB1_6:
152- retq
153- .LBB1_2:
154- jmp .LBB1_3
155- .LBB1_5:
156- jmp .LBB1_6
157- .Lfunc_end1:
158- .size main, .Lfunc_end1-main
139+ .size main, .-main
159140 .cfi_endproc
160141
161142 .section .text.hot._ZNK8Derived24funcEii,"axG",@progbits,_ZNK8Derived24funcEii,comdat
162143 .weak _ZNK8Derived24funcEii
163- .p2align 4, 0x90
164144 .type _ZNK8Derived24funcEii,@function
165145_ZNK8Derived24funcEii: #
166146 .cfi_startproc
167147 imull %esi, %eax
168148 retq
169- .Lfunc_end2:
170- .size _ZNK8Derived24funcEii, .Lfunc_end2-_ZNK8Derived24funcEii
149+ .size _ZNK8Derived24funcEii, .-_ZNK8Derived24funcEii
171150 .cfi_endproc
172151
173152 .section .text.unlikely._ZN8Derived2D0Ev,"axG",@progbits,_ZN8Derived2D0Ev,comdat
174153 .weak _ZN8Derived2D0Ev
175- .p2align 4, 0x90
176154 .type _ZN8Derived2D0Ev,@function
177155_ZN8Derived2D0Ev:
178156 .cfi_startproc
179- # %bb.0:
180157 movl $16, %esi
181158 jmp _ZdlPvm@PLT
182- .Lfunc_end3:
183- .size _ZN8Derived2D0Ev, .Lfunc_end3-_ZN8Derived2D0Ev
159+ .size _ZN8Derived2D0Ev, .-_ZN8Derived2D0Ev
184160 .cfi_endproc
185161
186162 .section .text.hot._ZNK8Derived34funcEii,"axG",@progbits,_ZNK8Derived34funcEii,comdat
187163 .weak _ZNK8Derived34funcEii
188- .p2align 4, 0x90
189164 .type _ZNK8Derived34funcEii,@function
190165_ZNK8Derived34funcEii:
191166 .cfi_startproc
192167 imull %esi, %eax
193168 retq
194- .Lfunc_end4:
195- .size _ZNK8Derived34funcEii, .Lfunc_end4-_ZNK8Derived34funcEii
169+ .size _ZNK8Derived34funcEii, .-_ZNK8Derived34funcEii
196170 .cfi_endproc
197171
198172 .section .text.unlikely._ZN4BaseD2Ev,"axG",@progbits,_ZN4BaseD2Ev,comdat
199173 .weak _ZN4BaseD2Ev
200- .p2align 4, 0x90
201174 .type _ZN4BaseD2Ev,@function
202175_ZN4BaseD2Ev:
203176 .cfi_startproc
204- # %bb.0:
205177 retq
206- .Lfunc_end5:
207- .size _ZN4BaseD2Ev, .Lfunc_end5-_ZN4BaseD2Ev
178+ .size _ZN4BaseD2Ev, .-_ZN4BaseD2Ev
208179 .cfi_endproc
209180
210181 .section .text.unlikely._ZN8Derived3D0Ev,"axG",@progbits,_ZN8Derived3D0Ev,comdat
211182 .weak _ZN8Derived3D0Ev
212- .p2align 4, 0x90
213183 .type _ZN8Derived3D0Ev,@function
214184_ZN8Derived3D0Ev:
215185 .cfi_startproc
216- # %bb.0:
217186 movl $16, %esi
218187 jmp _ZdlPvm@PLT
219- .Lfunc_end6:
220- .size _ZN8Derived3D0Ev, .Lfunc_end6-_ZN8Derived3D0Ev
188+ .size _ZN8Derived3D0Ev, .-_ZN8Derived3D0Ev
221189 .cfi_endproc
222190
223191 .type _ZTV8Derived2,@object
224192 .section .data.rel.ro._ZTV8Derived2,"awG",@progbits,_ZTV8Derived2,comdat
225193 .weak _ZTV8Derived2
226- .p2align 3, 0x0
227194_ZTV8Derived2:
228195 .quad 0
229196 .quad _ZTI8Derived2
@@ -249,7 +216,6 @@ _ZTS4Base:
249216 .type _ZTI4Base,@object
250217 .section .data.rel.ro._ZTI4Base,"awG",@progbits,_ZTI4Base,comdat
251218 .weak _ZTI4Base
252- .p2align 3, 0x0
253219_ZTI4Base:
254220 .quad _ZTVN10__cxxabiv117__class_type_infoE+16
255221 .quad _ZTS4Base
@@ -258,7 +224,6 @@ _ZTI4Base:
258224 .type _ZTI8Derived2,@object
259225 .section .data.rel.ro._ZTI8Derived2,"awG",@progbits,_ZTI8Derived2,comdat
260226 .weak _ZTI8Derived2
261- .p2align 3, 0x0
262227_ZTI8Derived2:
263228 .quad _ZTVN10__cxxabiv120__si_class_type_infoE+16
264229 .quad _ZTS8Derived2
@@ -268,7 +233,6 @@ _ZTI8Derived2:
268233 .type _ZTV8Derived3,@object
269234 .section .data.rel.ro._ZTV8Derived3,"awG",@progbits,_ZTV8Derived3,comdat
270235 .weak _ZTV8Derived3
271- .p2align 3, 0x0
272236_ZTV8Derived3:
273237 .quad 0
274238 .quad _ZTI8Derived3
@@ -287,7 +251,6 @@ _ZTS8Derived3:
287251 .type _ZTI8Derived3,@object
288252 .section .data.rel.ro._ZTI8Derived3,"awG",@progbits,_ZTI8Derived3,comdat
289253 .weak _ZTI8Derived3
290- .p2align 3, 0x0
291254_ZTI8Derived3:
292255 .quad _ZTVN10__cxxabiv120__si_class_type_infoE+16
293256 .quad _ZTS8Derived3
0 commit comments