brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 1fd49a7 Raw
40 lines · c
1/*2REQUIRES: system-linux,bolt-runtime3 4RUN: %clang %cflags %s -o %t.exe -Wl,-q 5 6RUN: llvm-bolt %t.exe --instrument --instrumentation-file=%t.fdata \7RUN:   -o %t.instrumented8 9# Instrumented program needs to finish returning zero10RUN: %t.instrumented | FileCheck %s -check-prefix=CHECK-OUTPUT11 12# Test that the instrumented data makes sense13RUN:  llvm-bolt %t.exe -o %t.bolted --data %t.fdata \14RUN:    --reorder-blocks=ext-tsp --reorder-functions=hfsort+ \15RUN:    --print-only=main --print-finalized | FileCheck %s16 17RUN: %t.bolted | FileCheck %s -check-prefix=CHECK-OUTPUT18 19CHECK-OUTPUT: The sum is: 3020 21# Check that our indirect call has 1 hit recorded in the fdata file and that22# this was processed correctly by BOLT23CHECK:         jalr    a2 # CallProfile: 1 (0 misses) :24CHECK-NEXT:    { add: 1 (0 misses) }25*/26 27#include <stdio.h>28 29typedef int (*func_ptr)(int, int);30 31int add(int a, int b) { return a + b; }32 33int main() {34  func_ptr fun;35  fun = add;36  int sum = fun(10, 20); // indirect call to 'add'37  printf("The sum is: %d\n", sum);38  return 0;39}40