summaryrefslogtreecommitdiff
path: root/test/profile/infinite_loop.c
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2017-11-30 19:37:56 +0000
committerXinliang David Li <davidxl@google.com>2017-11-30 19:37:56 +0000
commitc0e94832ed94d4a03f1e605b57a9c0908e7f8105 (patch)
tree88a3db9fe589f010b6dc793d41565a379fd2f99e /test/profile/infinite_loop.c
parent650232b9e9880c170e01a2a61b77871a30a245c5 (diff)
[PGO] Add a test case for infinite loops
Differential Revision: http://reviews.llvm.org/D40663 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319463 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/profile/infinite_loop.c')
-rw-r--r--test/profile/infinite_loop.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/profile/infinite_loop.c b/test/profile/infinite_loop.c
new file mode 100644
index 000000000..883d7e6da
--- /dev/null
+++ b/test/profile/infinite_loop.c
@@ -0,0 +1,30 @@
+// RUN: %clang_pgogen -O2 -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata show -function main -counts %t.profraw| FileCheck %s
+
+void exit(int);
+int g;
+__attribute__((noinline)) void foo()
+{
+ g++;
+ if (g==1000)
+ exit(0);
+}
+
+
+int main()
+{
+ while (1) {
+ foo();
+ }
+
+}
+
+// CHECK: Counters:
+// CHECK-NEXT: main:
+// CHECK-NEXT: Hash: {{.*}}
+// CHECK-NEXT: Counters: 1
+// CHECK-NEXT: Block counts: [1000]
+
+
+