3 # Generate a large test case and check that the output is deterministic.
5 # RUN: %python %s %t.s %t.proftext
7 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t.s -o %t.o
8 # RUN: llvm-profdata merge %t.proftext -o %t.profdata
10 # RUN: %no-fatal-warnings-lld -arch arm64 -lSystem -e _main --icf=all -o - %t.o --irpgo-profile-sort=%t.profdata --compression-sort-startup-functions --compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - > %t.order1.txt
11 # RUN: %no-fatal-warnings-lld -arch arm64 -lSystem -e _main --icf=all -o - %t.o --irpgo-profile-sort=%t.profdata --compression-sort-startup-functions --compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - > %t.order2.txt
12 # RUN: diff %t.order1.txt %t.order2.txt
14 # RUN: %lld -arch arm64 -lSystem -e _main --icf=all -o - %t.o --irpgo-profile=%t.profdata --bp-startup-sort=function --bp-compression-sort-startup-functions --bp-compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - > %t.order1.txt
15 # RUN: %lld -arch arm64 -lSystem -e _main --icf=all -o - %t.o --irpgo-profile=%t.profdata --bp-startup-sort=function --bp-compression-sort-startup-functions --bp-compression-sort=both | llvm-nm --numeric-sort --format=just-symbols - > %t.order2.txt
16 # RUN: diff %t.order1.txt %t.order2.txt
20 assembly_filepath
= sys.argv
[1]
21 proftext_filepath
= sys.argv
[2]
28 function_names
= [f
"f{n}" for n in range
(num_functions
)]
29 data_names
= [f
"d{n}" for n in range
(num_data
)]
30 profiled_functions
= function_names
[: int
(num_functions
/ 2)]
35 add w0, w0, #{i % 4096}
41 for i
, name in enumerate
(function_names
)
47 .ascii "s
{i
% 2}-{i
% 3}-{i
% 5}"
50 for i
, name in enumerate
(data_names
)
57 {", ".join(random.sample(profiled_functions, len(profiled_functions)))}
59 for i in range
(num_traces
)
72 for i
, name in enumerate
(profiled_functions
)
75 with open
(assembly_filepath
, "w") as f
:
84 {"".join(function_contents)}
87 {"".join(data_contents)}
89 .subsections_via_symbols
93 with open
(proftext_filepath
, "w") as f
:
104 {"".join(trace_contents)}
106 {"".join(profile_contents)}