brintos

brintos / llvm-project-archived public Read only

0
0
Text · 864 B · b55f5e2 Raw
37 lines · c
1// The waiting loop never exits via the normal2// path before the profile is dumped and the3// program is terminated. This tests checks4// that the entry of main is properly instrumented5// and has non-zero count.6 7// RUN: %clang_pgogen -mllvm -do-counter-promotion=false -O2 -o %t %s8// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t9// RUN: llvm-profdata show -function main -counts  %t.profraw| FileCheck  %s10void exit(int);11 12int __llvm_profile_dump(void);13void __llvm_profile_reset_counters(void);14 15int g = 0;16__attribute__((noinline)) void doSth() {17  g++;18 19  if (g > 10000) {20    // dump profile and exit;21    __llvm_profile_dump();22    exit(0);23  }24}25int errorcode = 0;26int noerror() { return (errorcode == 0); }27 28int main(int argc, const char *argv[]) {29  //  waiting_loop30  while (noerror()) {31    doSth();32  }33}34 35// CHECK-LABEL: main36// CHECK: [10001, 1]37