Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / runtime / X86 / instrumentation-pie.c
blob6c51f4c8cfb0b59dc97f29c89f2507ce2e3ba5fa
1 /* Checks that BOLT correctly handles instrumentation of executables built
2 * with PIE with further optimization.
3 */
4 #include <stdio.h>
6 int foo(int x) { return x + 1; }
8 int fib(int x) {
9 if (x < 2)
10 return x;
11 return fib(x - 1) + fib(x - 2);
14 int bar(int x) { return x - 1; }
16 int main(int argc, char **argv) {
17 printf("fib(%d) = %d\n", argc, fib(argc));
18 return 0;
22 REQUIRES: system-linux,bolt-runtime
24 RUN: %clang %cflags %s -o %t.exe -Wl,-q -pie -fpie
26 RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \
27 RUN: -o %t.instrumented
29 # Instrumented program needs to finish returning zero
30 RUN: %t.instrumented 1 2 3 | FileCheck %s -check-prefix=CHECK-OUTPUT
32 # Test that the instrumented data makes sense
33 RUN: llvm-bolt %t.exe -o %t.bolted --data %t.fdata \
34 RUN: --reorder-blocks=ext-tsp --reorder-functions=hfsort+
36 RUN: %t.bolted 1 2 3 | FileCheck %s -check-prefix=CHECK-OUTPUT
38 CHECK-OUTPUT: fib(4) = 3