2121# RUN: ld.lld a.o -- irpgo - profile=a.profdata -- bp - startup - sort=function -- verbose - bp - section - orderer -- icf=all 2 >& 1 | FileCheck %s -- check - prefix=STARTUP - FUNC - ORDER
2222
2323# STARTUP - FUNC - ORDER: Ordered 3 sections using balanced partitioning
24+ # STARTUP - FUNC - ORDER: Total area under the page fault curve: 3 .
2425
25- # RUN: ld.lld - o - a.o -- symbol - ordering - file a.orderfile -- irpgo - profile=a.profdata -- bp - startup - sort=function | llvm - nm -- numeric - sort -- form at =just - symbols - | FileCheck %s -- check - prefix=ORDERFILE
26- # RUN: ld.lld - o - a.o -- symbol - ordering - file a.orderfile -- bp - compression - sort=both | llvm - nm -- numeric - sort -- form at =just - symbols - | FileCheck %s -- check - prefix=ORDERFILE
26+ # RUN: ld.lld - o - a.o -- symbol - ordering - file a.txt -- irpgo - profile=a.profdata -- bp - startup - sort=function | llvm - nm -- numeric - sort -- form at =just - symbols - | FileCheck %s -- check - prefix=ORDERFILE
27+ # RUN: ld.lld - o - a.o -- symbol - ordering - file a.txt -- bp - compression - sort=both | llvm - nm -- numeric - sort -- form at =just - symbols - | FileCheck %s -- check - prefix=ORDERFILE
2728
2829## Rodata
2930# ORDERFILE: s2
3536# ORDERFILE - NEXT: F
3637# ORDERFILE - NEXT: E
3738# ORDERFILE - NEXT: D
38- # ORDERFILE - NEXT : B
39- # ORDERFILE - NEXT : C
39+ # ORDERFILE - DAG : B
40+ # ORDERFILE - DAG : C
4041# ORDERFILE - NEXT: _start
4142
4243## Data
9798# Counter Values:
98991
99100
100- # --- a.orderfile
101+ # --- a.txt
101102A
102103F
103104E
@@ -115,77 +116,80 @@ const char *r1 = s1;
115116const char ** r2 = &r1 ;
116117const char *** r3 = &r2 ;
117118const char * r4 = s2 ;
118- void A() { return ; }
119119
120- int B( int a) {
121- A() ;
122- return a + 1 ;
123- }
124-
125- int C( int a) {
126- A() ;
127- return a + 2 ;
128- }
129-
130- int D( int a) { return B(a + 2 ) ; }
131-
132- int E( int a) { return C(a + 2 ) ; }
120+ int C( int a) ;
121+ int B( int a) ;
122+ void A() ;
133123
134124int F( int a) { return C(a + 3 ) ; }
125+ int E( int a) { return C(a + 2 ) ; }
126+ int D( int a) { return B(a + 2 ) ; }
127+ int C( int a) { A() ; return a + 2; }
128+ int B( int a) { A() ; return a + 1; }
129+ void A() {}
135130
136131int _start() { return 0 ; }
137132
138133# --- gen
139134clang -- target=aarch64 - linux - gnu - O0 - ffunction - sections - fdata - sections - fno - asynchronous - unwind - tables - S a.c - o -
140135;--- a.s
141136 .file "a.c"
142- . section .text.A , "ax" , @progbits
143- .globl A // -- Begin function A
137+ . section .text.F , "ax" , @progbits
138+ .globl F // -- Begin function F
144139 .p2align 2
145- .type A , @function
146- A : // @A
140+ .type F , @function
141+ F : // @F
147142// %bb. 0 : // %entry
143+ sub sp , sp , # 32
144+ stp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Spill
145+ add x29 , sp , # 16
146+ stur w0 , [ x29 , # - 4 ]
147+ ldur w8 , [ x29 , # - 4 ]
148+ add w0 , w8 , # 3
149+ bl C
150+ ldp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Reload
151+ add sp , sp , # 32
148152 ret
149153.Lfunc_end0:
150- .size A , .Lfunc_end0 - A
154+ .size F , .Lfunc_end0 - F
151155 // -- End function
152- . section .text.B , "ax" , @progbits
153- .globl B // -- Begin function B
156+ . section .text.C , "ax" , @progbits
157+ .globl C // -- Begin function C
154158 .p2align 2
155- .type B , @function
156- B : // @B
159+ .type C , @function
160+ C : // @C
157161// %bb. 0 : // %entry
158162 sub sp , sp , # 32
159163 stp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Spill
160164 add x29 , sp , # 16
161165 stur w0 , [ x29 , # - 4 ]
162166 bl A
163167 ldur w8 , [ x29 , # - 4 ]
164- add w0 , w8 , # 1
168+ add w0 , w8 , # 2
165169 ldp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Reload
166170 add sp , sp , # 32
167171 ret
168172.Lfunc_end1:
169- .size B , .Lfunc_end1 - B
173+ .size C , .Lfunc_end1 - C
170174 // -- End function
171- . section .text.C , "ax" , @progbits
172- .globl C // -- Begin function C
175+ . section .text.E , "ax" , @progbits
176+ .globl E // -- Begin function E
173177 .p2align 2
174- .type C , @function
175- C : // @C
178+ .type E , @function
179+ E : // @E
176180// %bb. 0 : // %entry
177181 sub sp , sp , # 32
178182 stp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Spill
179183 add x29 , sp , # 16
180184 stur w0 , [ x29 , # - 4 ]
181- bl A
182185 ldur w8 , [ x29 , # - 4 ]
183186 add w0 , w8 , # 2
187+ bl C
184188 ldp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Reload
185189 add sp , sp , # 32
186190 ret
187191.Lfunc_end2:
188- .size C , .Lfunc_end2 - C
192+ .size E , .Lfunc_end2 - E
189193 // -- End function
190194 . section .text.D , "ax" , @progbits
191195 .globl D // -- Begin function D
@@ -206,43 +210,34 @@ D: // @D
206210.Lfunc_end3:
207211 .size D , .Lfunc_end3 - D
208212 // -- End function
209- . section .text.E , "ax" , @progbits
210- .globl E // -- Begin function E
213+ . section .text.B , "ax" , @progbits
214+ .globl B // -- Begin function B
211215 .p2align 2
212- .type E , @function
213- E : // @E
216+ .type B , @function
217+ B : // @B
214218// %bb. 0 : // %entry
215219 sub sp , sp , # 32
216220 stp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Spill
217221 add x29 , sp , # 16
218222 stur w0 , [ x29 , # - 4 ]
223+ bl A
219224 ldur w8 , [ x29 , # - 4 ]
220- add w0 , w8 , # 2
221- bl C
225+ add w0 , w8 , # 1
222226 ldp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Reload
223227 add sp , sp , # 32
224228 ret
225229.Lfunc_end4:
226- .size E , .Lfunc_end4 - E
230+ .size B , .Lfunc_end4 - B
227231 // -- End function
228- . section .text.F , "ax" , @progbits
229- .globl F // -- Begin function F
232+ . section .text.A , "ax" , @progbits
233+ .globl A // -- Begin function A
230234 .p2align 2
231- .type F , @function
232- F : // @F
235+ .type A , @function
236+ A : // @A
233237// %bb. 0 : // %entry
234- sub sp , sp , # 32
235- stp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Spill
236- add x29 , sp , # 16
237- stur w0 , [ x29 , # - 4 ]
238- ldur w8 , [ x29 , # - 4 ]
239- add w0 , w8 , # 3
240- bl C
241- ldp x29 , x30 , [ sp , # 16 ] // 16 - byte Folded Reload
242- add sp , sp , # 32
243238 ret
244239.Lfunc_end5:
245- .size F , .Lfunc_end5 - F
240+ .size A , .Lfunc_end5 - A
246241 // -- End function
247242 . section .text._start , "ax" , @progbits
248243 .globl _start // -- Begin function _start
310305
311306 . section ".note.GNU-stack" , "" , @progbits
312307 .addrsig
313- .addrsig_sym A
314- .addrsig_sym B
315308 .addrsig_sym C
309+ .addrsig_sym B
310+ .addrsig_sym A
316311 .addrsig_sym s1
317312 .addrsig_sym s2
318313 .addrsig_sym r1
0 commit comments