brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · b3744f5 Raw
48 lines · c
1// RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=3 -o %t %s2// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t3// RUN: llvm-profdata merge -o %t.profdata %t.profraw4// RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata | FileCheck %s5 6// IR level instrumentation7// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true  -mllvm -vp-counters-per-site=3 -o %t.ir  %s8// RUN: env LLVM_PROFILE_FILE=%t.ir.profraw %run %t.ir9// RUN: llvm-profdata merge -o %t.ir.profdata %t.ir.profraw10// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.profdata | FileCheck  %s11 12// IR level instrumentation, dynamic allocation13// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -o %t.ir.dyn  %s14// RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn15// RUN: llvm-profdata merge -o %t.ir.dyn.profdata %t.ir.dyn.profraw16// RUN: llvm-profdata show --all-functions -ic-targets  %t.ir.dyn.profdata | FileCheck  %s17void callee_0() {}18void callee_1() {}19void callee_2() {}20 21void *CalleeAddrs[] = {callee_0, callee_1, callee_2, callee_2, callee_2};22extern void lprofSetMaxValsPerSite(unsigned);23extern void __llvm_profile_reset_counters();24 25typedef void (*FPT)(void);26 27 28// Testing value profiling eviction algorithm.29FPT getCalleeFunc(int I) { return CalleeAddrs[I]; }30 31int main() {32  int I;33 34  // First fill up two value profile entries with two targets35  lprofSetMaxValsPerSite(2);36 37  for (I = 0; I < 5; I++) {38    if (I == 2) {39      __llvm_profile_reset_counters();40    }41    // CHECK:  callee_2, 342    // CHECK-NEXT: callee_1, 043    // CHECK-NOT: callee_0,44    FPT FP = getCalleeFunc(I);45    FP();46  }47}48