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
8int foo(int x) {
9 return x + 1;
10}
11
12int fib(int x) {
13 if (x < 2)
14 return x;
15 return fib(x: x - 1) + fib(x: x - 2);
16}
17
18int bar(int x) {
19 return x - 1;
20}
21
22int main(int argc, char **argv) {
23 printf(format: "fib(%d) = %d\n", argc, fib(x: argc));
24 return 0;
25}
26
27/*
28REQUIRES: system-linux,bolt-runtime
29
30RUN: %clang %cflags -no-pie %s -o %t.exe -Wl,-q
31
32RUN: llvm-bolt %t.exe --relocs=1 --lite --reorder-functions=user \
33RUN: --hugify --function-order=%p/Inputs/user_func_order.txt -o %t
34RUN: llvm-nm --numeric-sort --print-armap %t | \
35RUN: FileCheck %s -check-prefix=CHECK-NM
36RUN: %t 1 2 3 | FileCheck %s -check-prefix=CHECK-OUTPUT
37
38CHECK-NM: W __hot_start
39CHECK-NM: T main
40CHECK-NM-NEXT: T fib
41CHECK-NM-NEXT: W __hot_end
42
43CHECK-OUTPUT: fib(4) = 3
44*/
45

source code of bolt/test/runtime/X86/user-func-reorder.c