brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · c9e12ea Raw
55 lines · c
1/* Checks that BOLT correctly processes a user-provided function list file,2 * reorder functions according to this list, update hot_start and hot_end3 * symbols and insert a function to perform hot text mapping during program4 * startup.5 */6#include <stdio.h>7 8int foo(int x) { return x + 1; }9 10int fib(int x) {11  if (x < 2)12    return x;13  return fib(x - 1) + fib(x - 2);14}15 16int bar(int x) { return x - 1; }17 18int main(int argc, char **argv) {19  printf("fib(%d) = %d\n", argc, fib(argc));20  return 0;21}22 23/*24REQUIRES: system-linux,bolt-runtime25 26RUN: %clang %cflags -no-pie %s -o %t.exe -Wl,-q27 28RUN: llvm-bolt %t.exe --relocs=1 --lite --reorder-functions=user \29RUN:   --hugify --function-order=%p/Inputs/user_func_order.txt -o %t30RUN: llvm-bolt %t.exe --relocs=1 --lite --reorder-functions=user \31RUN:   --function-order=%p/Inputs/user_func_order.txt -o %t.nohugify32RUN: llvm-nm --numeric-sort --print-armap %t | \33RUN:   FileCheck %s -check-prefix=CHECK-NM34RUN: %t 1 2 3 | FileCheck %s -check-prefix=CHECK-OUTPUT35RUN: llvm-nm --numeric-sort --print-armap %t.nohugify | \36RUN:   FileCheck %s -check-prefix=CHECK-NM-NOHUGIFY37RUN: %t.nohugify 1 2 3 | FileCheck %s -check-prefix=CHECK-OUTPUT-NOHUGIFY38 39 40CHECK-NM:      W  __hot_start41CHECK-NM:      T main42CHECK-NM-NEXT: T fib43CHECK-NM-NEXT: W __hot_end44CHECK-NM: t __bolt_hugify_start_program45CHECK-NM-NEXT: W __bolt_runtime_start46 47CHECK-NM-NOHUGIFY:      W  __hot_start48CHECK-NM-NOHUGIFY:      T main49CHECK-NM-NOHUGIFY-NEXT: T fib50CHECK-NM-NOHUGIFY-NEXT: W __hot_end51 52CHECK-OUTPUT: fib(4) = 353CHECK-OUTPUT-NOHUGIFY: fib(4) = 354*/55