3 typedef int (*func_ptr
)(int, int);
5 int add(int a
, int b
) { return a
+ b
; }
10 int sum
= fun(10, 20); // indirect call to 'add'
11 printf("The sum is: %d\n", sum
);
15 REQUIRES: system-linux,bolt-runtime
17 RUN: %clang %cflags %s -o %t.exe -Wl,-q -nopie -fpie
19 RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \
20 RUN: -o %t.instrumented
22 # Instrumented program needs to finish returning zero
23 RUN: %t.instrumented | FileCheck %s -check-prefix=CHECK-OUTPUT
25 # Test that the instrumented data makes sense
26 RUN: llvm-bolt %t.exe -o %t.bolted --data %t.fdata \
27 RUN: --reorder-blocks=ext-tsp --reorder-functions=hfsort+ \
28 RUN: --print-only=main --print-finalized | FileCheck %s
30 RUN: %t.bolted | FileCheck %s -check-prefix=CHECK-OUTPUT
32 CHECK-OUTPUT: The sum is: 30
34 # Check that our indirect call has 1 hit recorded in the fdata file and that
35 # this was processed correctly by BOLT
36 CHECK: blr x8 # CallProfile: 1 (0 misses) :
37 CHECK-NEXT: { add: 1 (0 misses) }