1 /* Checks that BOLT correctly handles instrumentation of indirect calls
2 * including case with indirect calls in signals handlers.
10 int foo(int x
) { return x
+ 1; }
12 int bar(int (*fn
)(int), int val
) { return fn(val
); }
14 void sigHandler(int signum
) { bar(foo
, 3); }
16 int main(int argc
, char **argv
) {
20 signal(SIGUSR1
, sigHandler
);
26 wpid
= waitpid(pid
, &wstatus
, WNOHANG
);
30 for (i
= 0; i
< 100000; i
++) {
39 REQUIRES: system-linux,bolt-runtime,lit-max-individual-test-time
41 RUN: %clang %cflags %s -o %t.exe -Wl,-q -pie -fpie
43 RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \
44 RUN: --instrumentation-wait-forks=1 --conservative-instrumentation \
45 RUN: -o %t.instrumented_conservative
47 # Instrumented program needs to finish returning zero
48 RUN: %t.instrumented_conservative | FileCheck %s -check-prefix=CHECK-OUTPUT
50 RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \
51 RUN: --instrumentation-wait-forks=1 \
52 RUN: -o %t.instrumented
54 # Instrumented program needs to finish returning zero
55 RUN: %t.instrumented | FileCheck %s -check-prefix=CHECK-OUTPUT
57 # Test that the instrumented data makes sense
58 RUN: llvm-bolt %t.exe -o %t.bolted --data %t.fdata \
59 RUN: --reorder-blocks=ext-tsp --reorder-functions=hfsort+ \
60 RUN: --print-only=interp --print-finalized
62 RUN: %t.bolted | FileCheck %s -check-prefix=CHECK-OUTPUT
65 CHECK-OUTPUT: [parent]