1 | /* Checks that BOLT correctly processes a user-provided function list file, |
2 | * reorder functions according to this list, update hot_start and hot_end |
3 | * symbols and insert a function to perform hot text mapping during program |
4 | * startup. |
5 | */ |
6 | #include <stdio.h> |
7 | |
8 | int foo(int x) { |
9 | return x + 1; |
10 | } |
11 | |
12 | int fib(int x) { |
13 | if (x < 2) |
14 | return x; |
15 | return fib(x: x - 1) + fib(x: x - 2); |
16 | } |
17 | |
18 | int bar(int x) { |
19 | return x - 1; |
20 | } |
21 | |
22 | int main(int argc, char **argv) { |
23 | printf(format: "fib(%d) = %d\n" , argc, fib(x: argc)); |
24 | return 0; |
25 | } |
26 | |
27 | /* |
28 | REQUIRES: system-linux,bolt-runtime |
29 | |
30 | RUN: %clang %cflags -no-pie %s -o %t.exe -Wl,-q |
31 | |
32 | RUN: llvm-bolt %t.exe --relocs=1 --lite --reorder-functions=user \ |
33 | RUN: --hugify --function-order=%p/Inputs/user_func_order.txt -o %t |
34 | RUN: llvm-nm --numeric-sort --print-armap %t | \ |
35 | RUN: FileCheck %s -check-prefix=CHECK-NM |
36 | RUN: %t 1 2 3 | FileCheck %s -check-prefix=CHECK-OUTPUT |
37 | |
38 | CHECK-NM: W __hot_start |
39 | CHECK-NM: T main |
40 | CHECK-NM-NEXT: T fib |
41 | CHECK-NM-NEXT: W __hot_end |
42 | |
43 | CHECK-OUTPUT: fib(4) = 3 |
44 | */ |
45 | |