annotate clang/test/Profile/c-captured.c @ 237:c80f45b162ad llvm-original

add some fix
author kono
date Wed, 09 Nov 2022 17:47:54 +0900
parents c4bab56944e8
children 1f2b6ac9f198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
1 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOGEN -check-prefix=PGOALL %s
150
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // RUN: llvm-profdata merge %S/Inputs/c-captured.proftext -o %t.profdata
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
4 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE -check-prefix=PGOALL %s
150
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 // PGOGEN: @[[DCC:__profc_debug_captured]] = private global [3 x i64] zeroinitializer
anatofuz
parents:
diff changeset
7 // PGOGEN: @[[CSC:__profc_c_captured.c___captured_stmt]] = private global [2 x i64] zeroinitializer
anatofuz
parents:
diff changeset
8 // PGOGEN: @[[C1C:__profc_c_captured.c___captured_stmt.1]] = private global [3 x i64] zeroinitializer
anatofuz
parents:
diff changeset
9
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
10 // PGOALL-LABEL: define{{.*}} void @debug_captured()
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
11 // PGOGEN: store {{.*}} @[[DCC]], i32 0, i32 0
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
12 void debug_captured(void) {
150
anatofuz
parents:
diff changeset
13 int x = 10;
anatofuz
parents:
diff changeset
14
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
15 // Check both debug_captured counters, so we can do this all in one pass
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
16 // PGOGEN: store {{.*}} @[[DCC]], i32 0, i32 1
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
17 // PGOUSE: br {{.*}} !prof ![[DC1:[0-9]+]]
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
18 // PGOGEN: store {{.*}} @[[DCC]], i32 0, i32 2
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
19 // PGOUSE: br {{.*}} !prof ![[DC2:[0-9]+]]
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
20 // PGOALL: ret
150
anatofuz
parents:
diff changeset
21
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
22 // PGOALL-LABEL: define internal void @__captured_stmt(
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
23 // PGOGEN: store {{.*}} @[[CSC]], i32 0, i32 0
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
24 #pragma clang __debug captured
150
anatofuz
parents:
diff changeset
25 {
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
26 // PGOGEN: store {{.*}} @[[CSC]], i32 0, i32 1
150
anatofuz
parents:
diff changeset
27 // PGOUSE: br {{.*}} !prof ![[CS1:[0-9]+]]
anatofuz
parents:
diff changeset
28 if (x) {}
anatofuz
parents:
diff changeset
29 // PGOALL: ret
anatofuz
parents:
diff changeset
30 }
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 if (x) {} // This is DC1. Checked above.
anatofuz
parents:
diff changeset
33
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
34 // PGOALL-LABEL: define internal void @__captured_stmt.1(
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
35 // PGOGEN: store {{.*}} @[[C1C]], i32 0, i32 0
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
36 #pragma clang __debug captured
150
anatofuz
parents:
diff changeset
37 {
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
38 // PGOGEN: store {{.*}} @[[C1C]], i32 0, i32 1
150
anatofuz
parents:
diff changeset
39 // PGOUSE: br {{.*}} !prof ![[C11:[0-9]+]]
anatofuz
parents:
diff changeset
40 for (int i = 0; i < x; ++i) {}
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
41 // PGOGEN: store {{.*}} @[[C1C]], i32 0, i32 2
150
anatofuz
parents:
diff changeset
42 // PGOUSE: br {{.*}} !prof ![[C12:[0-9]+]]
anatofuz
parents:
diff changeset
43 if (x) {}
anatofuz
parents:
diff changeset
44 // PGOALL: ret
anatofuz
parents:
diff changeset
45 }
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 if (x) {} // This is DC2. Checked above.
anatofuz
parents:
diff changeset
48 }
anatofuz
parents:
diff changeset
49
anatofuz
parents:
diff changeset
50 // PGOUSE-DAG: ![[DC1]] = !{!"branch_weights", i32 2, i32 1}
anatofuz
parents:
diff changeset
51 // PGOUSE-DAG: ![[DC2]] = !{!"branch_weights", i32 2, i32 1}
anatofuz
parents:
diff changeset
52 // PGOUSE-DAG: ![[CS1]] = !{!"branch_weights", i32 2, i32 1}
anatofuz
parents:
diff changeset
53 // PGOUSE-DAG: ![[C11]] = !{!"branch_weights", i32 11, i32 2}
anatofuz
parents:
diff changeset
54 // PGOUSE-DAG: ![[C12]] = !{!"branch_weights", i32 2, i32 1}
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 int main(int argc, const char *argv[]) {
anatofuz
parents:
diff changeset
57 debug_captured();
anatofuz
parents:
diff changeset
58 return 0;
anatofuz
parents:
diff changeset
59 }