442 lines · plain
1# NOTE: Code has been autogenerated by utils/update_test_body.py2# REQUIRES: aarch643# RUN: rm -rf %t && split-file %s %t && cd %t4 5## Check for incompatible cases6# RUN: not ld.lld %t --irpgo-profile=/dev/null --bp-startup-sort=function --call-graph-ordering-file=/dev/null 2>&1 | FileCheck %s --check-prefix=BP-STARTUP-CALLGRAPH-ERR7# RUN: not ld.lld --bp-compression-sort=function --call-graph-ordering-file /dev/null 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-CALLGRAPH-ERR8# RUN: not ld.lld --bp-startup-sort=function 2>&1 | FileCheck %s --check-prefix=BP-STARTUP-ERR9# RUN: not ld.lld --bp-compression-sort-startup-functions 2>&1 | FileCheck %s --check-prefix=BP-STARTUP-COMPRESSION-ERR10# RUN: not ld.lld --bp-startup-sort=invalid --bp-compression-sort=invalid 2>&1 | FileCheck %s --check-prefix=BP-INVALID11 12# BP-STARTUP-CALLGRAPH-ERR: error: --bp-startup-sort=function is incompatible with --call-graph-ordering-file13# BP-COMPRESSION-CALLGRAPH-ERR: error: --bp-compression-sort is incompatible with --call-graph-ordering-file14# BP-STARTUP-ERR: error: --bp-startup-sort=function must be used with --irpgo-profile15# BP-STARTUP-COMPRESSION-ERR: error: --bp-compression-sort-startup-functions must be used with --irpgo-profile16 17# BP-INVALID: error: --bp-compression-sort=: expected [none|function|data|both]18# BP-INVALID: error: --bp-startup-sort=: expected [none|function]19 20# RUN: llvm-mc -filetype=obj -triple=aarch64 a.s -o a.o21# RUN: llvm-profdata merge a.proftext -o a.profdata22# RUN: ld.lld a.o --irpgo-profile=a.profdata --bp-startup-sort=function --verbose-bp-section-orderer --icf=all --gc-sections 2>&1 | FileCheck %s --check-prefix=STARTUP-FUNC-ORDER23 24# STARTUP-FUNC-ORDER: Ordered 4 sections ([[#]] bytes) using balanced partitioning25# STARTUP-FUNC-ORDER: Total area under the page fault curve: 4.26 27# RUN: ld.lld -o out.s a.o --irpgo-profile=a.profdata --bp-startup-sort=function28# RUN: llvm-nm -jn out.s | tr '\n' , | FileCheck %s --check-prefix=STARTUP29# STARTUP: s5,s4,s3,s2,s1,A,B,C,L1,F,E,D,merged1,merged2,G,_start,d4,d3,d2,d1,g1,{{$}}30 31# RUN: ld.lld -o out.os a.o --irpgo-profile=a.profdata --bp-startup-sort=function --symbol-ordering-file a.txt32# RUN: llvm-nm -jn out.os | tr '\n' , | FileCheck %s --check-prefix=ORDER-STARTUP33# ORDER-STARTUP: s2,s1,s5,s4,s3,A,F,E,D,B,C,L1,merged1,merged2,G,_start,d3,d2,d4,d1,g1,{{$}}34 35# RUN: ld.lld -o out.cf a.o --verbose-bp-section-orderer --bp-compression-sort=function 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-FUNC36# RUN: ld.lld -o out.cf.icf a.o --verbose-bp-section-orderer --bp-compression-sort=function --icf=all --gc-sections 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-ICF-FUNC37# RUN: llvm-nm -jn out.cf | tr '\n' , | FileCheck %s --check-prefix=CFUNC38# CFUNC: s5,s4,s3,s2,s1,C,E,D,B,G,F,merged1,merged2,A,_start,L1,d4,d3,d2,d1,g1,{{$}}39 40# RUN: ld.lld -o out.cd a.o --verbose-bp-section-orderer --bp-compression-sort=data 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-DATA41# RUN: llvm-nm -jn out.cd | tr '\n' , | FileCheck %s --check-prefix=CDATA42# CDATA: s5,s3,s4,s2,s1,F,C,E,D,B,A,merged1,merged2,L1,G,_start,d4,d1,d3,d2,g1,{{$}}43 44# RUN: ld.lld -o out.cb a.o --verbose-bp-section-orderer --bp-compression-sort=both 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-BOTH45# RUN: llvm-nm -jn out.cb | tr '\n' , | FileCheck %s --check-prefix=CBOTH46# CBOTH: s5,s3,s4,s2,s1,C,E,D,B,G,F,merged1,merged2,A,_start,L1,d4,d1,d3,d2,g1,{{$}}47 48# RUN: ld.lld -o out.cbs a.o --verbose-bp-section-orderer --bp-compression-sort=both --irpgo-profile=a.profdata --bp-startup-sort=function 2>&1 | FileCheck %s --check-prefix=BP-COMPRESSION-BOTH49# RUN: llvm-nm -jn out.cbs | tr '\n' , | FileCheck %s --check-prefix=CBOTH-STARTUP50# CBOTH-STARTUP: s5,s3,s4,s2,s1,A,B,C,L1,F,E,D,merged1,merged2,G,_start,d4,d1,d3,d2,g1,{{$}}51 52# BP-COMPRESSION-FUNC: Ordered 11 sections ([[#]] bytes) using balanced partitioning53# BP-COMPRESSION-ICF-FUNC: Ordered 9 sections ([[#]] bytes) using balanced partitioning54# BP-COMPRESSION-DATA: Ordered 9 sections ([[#]] bytes) using balanced partitioning55# BP-COMPRESSION-BOTH: Ordered 20 sections ([[#]] bytes) using balanced partitioning56 57#--- a.proftext58:ir59:temporal_prof_traces60# Num Traces61162# Trace Stream Size:63164# Weight65166A, B, C, L167 68A69# Func Hash:70111171# Num Counters:72173# Counter Values:74175 76B77# Func Hash:78222279# Num Counters:80181# Counter Values:82183 84C85# Func Hash:86333387# Num Counters:88189# Counter Values:90191 92D93# Func Hash:94444495# Num Counters:96197# Counter Values:98199 100L1101# Func Hash:1025555103# Num Counters:1041105# Counter Values:1061107 108#--- a.txt109A110F111E112D113s2114s1115d3116d2117 118#--- a.c119int g1;120const char s5[] = "engineering";121const char s4[] = "computer program";122const char s3[] = "hardware engineer";123const char s2[] = "computer software";124const char s1[] = "hello world program";125int d4[] = {1,2,3,4,5,6};126int d3[] = {5,6,7,8};127int d2[] = {7,8,9,10};128int d1[] = {3,4,5,6};129 130// used is to suppress compiler garbage collection in ELF; retain is to suppress linker garbage collection; used is not needed for non-internal linkage symbols131// used is for both compiler/linker GC in Mach-O; retain is ignored for Mach-O132#define RETAIN [[gnu::used,gnu::retain]]133 134int C(int a);135int B(int a);136void A();137 138int F(int a) { return C(a + 3); }139RETAIN int E(int a) { return C(a + 2); }140RETAIN int D(int a) { return B(a + 2); }141int C(int a) { A(); return a + 2; }142int B(int a) { A(); return a + 1; }143void A() {}144 145RETAIN int merged1(int a) { return F(a + 101); }146int merged2(int a) { return F(a + 101); }147 148RETAIN static int L1(int a) { return a + 103; }149int G(int a) { return L1(a); }150 151int _start() { return 0; }152 153#--- gen154clang --target=aarch64-linux-gnu -O0 -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -S a.c -o -155;--- a.s156 .file "a.c"157 .section .text.F,"ax",@progbits158 .globl F // -- Begin function F159 .p2align 2160 .type F,@function161F: // @F162// %bb.0:163 sub sp, sp, #32164 stp x29, x30, [sp, #16] // 16-byte Folded Spill165 add x29, sp, #16166 stur w0, [x29, #-4]167 ldur w8, [x29, #-4]168 add w0, w8, #3169 bl C170 ldp x29, x30, [sp, #16] // 16-byte Folded Reload171 add sp, sp, #32172 ret173.Lfunc_end0:174 .size F, .Lfunc_end0-F175 // -- End function176 .section .text.C,"ax",@progbits177 .globl C // -- Begin function C178 .p2align 2179 .type C,@function180C: // @C181// %bb.0:182 sub sp, sp, #32183 stp x29, x30, [sp, #16] // 16-byte Folded Spill184 add x29, sp, #16185 stur w0, [x29, #-4]186 bl A187 ldur w8, [x29, #-4]188 add w0, w8, #2189 ldp x29, x30, [sp, #16] // 16-byte Folded Reload190 add sp, sp, #32191 ret192.Lfunc_end1:193 .size C, .Lfunc_end1-C194 // -- End function195 .section .text.E,"axR",@progbits196 .globl E // -- Begin function E197 .p2align 2198 .type E,@function199E: // @E200// %bb.0:201 sub sp, sp, #32202 stp x29, x30, [sp, #16] // 16-byte Folded Spill203 add x29, sp, #16204 stur w0, [x29, #-4]205 ldur w8, [x29, #-4]206 add w0, w8, #2207 bl C208 ldp x29, x30, [sp, #16] // 16-byte Folded Reload209 add sp, sp, #32210 ret211.Lfunc_end2:212 .size E, .Lfunc_end2-E213 // -- End function214 .section .text.D,"axR",@progbits215 .globl D // -- Begin function D216 .p2align 2217 .type D,@function218D: // @D219// %bb.0:220 sub sp, sp, #32221 stp x29, x30, [sp, #16] // 16-byte Folded Spill222 add x29, sp, #16223 stur w0, [x29, #-4]224 ldur w8, [x29, #-4]225 add w0, w8, #2226 bl B227 ldp x29, x30, [sp, #16] // 16-byte Folded Reload228 add sp, sp, #32229 ret230.Lfunc_end3:231 .size D, .Lfunc_end3-D232 // -- End function233 .section .text.B,"ax",@progbits234 .globl B // -- Begin function B235 .p2align 2236 .type B,@function237B: // @B238// %bb.0:239 sub sp, sp, #32240 stp x29, x30, [sp, #16] // 16-byte Folded Spill241 add x29, sp, #16242 stur w0, [x29, #-4]243 bl A244 ldur w8, [x29, #-4]245 add w0, w8, #1246 ldp x29, x30, [sp, #16] // 16-byte Folded Reload247 add sp, sp, #32248 ret249.Lfunc_end4:250 .size B, .Lfunc_end4-B251 // -- End function252 .section .text.A,"ax",@progbits253 .globl A // -- Begin function A254 .p2align 2255 .type A,@function256A: // @A257// %bb.0:258 ret259.Lfunc_end5:260 .size A, .Lfunc_end5-A261 // -- End function262 .section .text.merged1,"axR",@progbits263 .globl merged1 // -- Begin function merged1264 .p2align 2265 .type merged1,@function266merged1: // @merged1267// %bb.0:268 sub sp, sp, #32269 stp x29, x30, [sp, #16] // 16-byte Folded Spill270 add x29, sp, #16271 stur w0, [x29, #-4]272 ldur w8, [x29, #-4]273 add w0, w8, #101274 bl F275 ldp x29, x30, [sp, #16] // 16-byte Folded Reload276 add sp, sp, #32277 ret278.Lfunc_end6:279 .size merged1, .Lfunc_end6-merged1280 // -- End function281 .section .text.merged2,"ax",@progbits282 .globl merged2 // -- Begin function merged2283 .p2align 2284 .type merged2,@function285merged2: // @merged2286// %bb.0:287 sub sp, sp, #32288 stp x29, x30, [sp, #16] // 16-byte Folded Spill289 add x29, sp, #16290 stur w0, [x29, #-4]291 ldur w8, [x29, #-4]292 add w0, w8, #101293 bl F294 ldp x29, x30, [sp, #16] // 16-byte Folded Reload295 add sp, sp, #32296 ret297.Lfunc_end7:298 .size merged2, .Lfunc_end7-merged2299 // -- End function300 .section .text.L1,"axR",@progbits301 .p2align 2 // -- Begin function L1302 .type L1,@function303L1: // @L1304// %bb.0:305 sub sp, sp, #16306 str w0, [sp, #12]307 ldr w8, [sp, #12]308 add w0, w8, #103309 add sp, sp, #16310 ret311.Lfunc_end8:312 .size L1, .Lfunc_end8-L1313 // -- End function314 .section .text.G,"ax",@progbits315 .globl G // -- Begin function G316 .p2align 2317 .type G,@function318G: // @G319// %bb.0:320 sub sp, sp, #32321 stp x29, x30, [sp, #16] // 16-byte Folded Spill322 add x29, sp, #16323 stur w0, [x29, #-4]324 ldur w0, [x29, #-4]325 bl L1326 ldp x29, x30, [sp, #16] // 16-byte Folded Reload327 add sp, sp, #32328 ret329.Lfunc_end9:330 .size G, .Lfunc_end9-G331 // -- End function332 .section .text._start,"ax",@progbits333 .globl _start // -- Begin function _start334 .p2align 2335 .type _start,@function336_start: // @_start337// %bb.0:338 mov w0, wzr339 ret340.Lfunc_end10:341 .size _start, .Lfunc_end10-_start342 // -- End function343 .type s5,@object // @s5344 .section .rodata.s5,"a",@progbits345 .globl s5346s5:347 .asciz "engineering"348 .size s5, 12349 350 .type s4,@object // @s4351 .section .rodata.s4,"a",@progbits352 .globl s4353s4:354 .asciz "computer program"355 .size s4, 17356 357 .type s3,@object // @s3358 .section .rodata.s3,"a",@progbits359 .globl s3360s3:361 .asciz "hardware engineer"362 .size s3, 18363 364 .type s2,@object // @s2365 .section .rodata.s2,"a",@progbits366 .globl s2367s2:368 .asciz "computer software"369 .size s2, 18370 371 .type s1,@object // @s1372 .section .rodata.s1,"a",@progbits373 .globl s1374s1:375 .asciz "hello world program"376 .size s1, 20377 378 .type d4,@object // @d4379 .section .data.d4,"aw",@progbits380 .globl d4381 .p2align 2, 0x0382d4:383 .word 1 // 0x1384 .word 2 // 0x2385 .word 3 // 0x3386 .word 4 // 0x4387 .word 5 // 0x5388 .word 6 // 0x6389 .size d4, 24390 391 .type d3,@object // @d3392 .section .data.d3,"aw",@progbits393 .globl d3394 .p2align 2, 0x0395d3:396 .word 5 // 0x5397 .word 6 // 0x6398 .word 7 // 0x7399 .word 8 // 0x8400 .size d3, 16401 402 .type d2,@object // @d2403 .section .data.d2,"aw",@progbits404 .globl d2405 .p2align 2, 0x0406d2:407 .word 7 // 0x7408 .word 8 // 0x8409 .word 9 // 0x9410 .word 10 // 0xa411 .size d2, 16412 413 .type d1,@object // @d1414 .section .data.d1,"aw",@progbits415 .globl d1416 .p2align 2, 0x0417d1:418 .word 3 // 0x3419 .word 4 // 0x4420 .word 5 // 0x5421 .word 6 // 0x6422 .size d1, 16423 424 .type g1,@object // @g1425 .section .bss.g1,"aw",@nobits426 .globl g1427 .p2align 2, 0x0428g1:429 .word 0 // 0x0430 .size g1, 4431 432 .section ".note.GNU-stack","",@progbits433 .addrsig434 .addrsig_sym F435 .addrsig_sym C436 .addrsig_sym E437 .addrsig_sym D438 .addrsig_sym B439 .addrsig_sym A440 .addrsig_sym merged1441 .addrsig_sym L1442