Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / runtime_infinite.c
blobb55f5e2750dd946c91c4566c071a558380817c49
1 // The waiting loop never exits via the normal
2 // path before the profile is dumped and the
3 // program is terminated. This tests checks
4 // that the entry of main is properly instrumented
5 // and has non-zero count.
7 // RUN: %clang_pgogen -mllvm -do-counter-promotion=false -O2 -o %t %s
8 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
9 // RUN: llvm-profdata show -function main -counts %t.profraw| FileCheck %s
10 void exit(int);
12 int __llvm_profile_dump(void);
13 void __llvm_profile_reset_counters(void);
15 int g = 0;
16 __attribute__((noinline)) void doSth() {
17 g++;
19 if (g > 10000) {
20 // dump profile and exit;
21 __llvm_profile_dump();
22 exit(0);
25 int errorcode = 0;
26 int noerror() { return (errorcode == 0); }
28 int main(int argc, const char *argv[]) {
29 // waiting_loop
30 while (noerror()) {
31 doSth();
35 // CHECK-LABEL: main
36 // CHECK: [10001, 1]