Justin Bogner | 81ab90f | 2014-04-15 00:50:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN -check-prefix=PGOALL %s |
Justin Bogner | 534f14a | 2014-04-17 22:49:06 +0000 | [diff] [blame] | 2 | |
| 3 | // RUN: llvm-profdata merge %S/Inputs/c-captured.proftext -o %t.profdata |
| 4 | // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE -check-prefix=PGOALL %s |
Justin Bogner | 81ab90f | 2014-04-15 00:50:54 +0000 | [diff] [blame] | 5 | |
Duncan P. N. Exon Smith | 9121220 | 2014-05-16 01:24:00 +0000 | [diff] [blame] | 6 | // PGOGEN: @[[DCC:__llvm_profile_counters_debug_captured]] = hidden global [3 x i64] zeroinitializer |
Justin Bogner | 81ab90f | 2014-04-15 00:50:54 +0000 | [diff] [blame] | 7 | // PGOGEN: @[[CSC:__llvm_profile_counters___captured_stmt]] = internal global [2 x i64] zeroinitializer |
| 8 | // PGOGEN: @[[C1C:__llvm_profile_counters___captured_stmt1]] = internal global [3 x i64] zeroinitializer |
| 9 | |
| 10 | // PGOALL-LABEL: define void @debug_captured() |
| 11 | // PGOGEN: store {{.*}} @[[DCC]], i64 0, i64 0 |
| 12 | void debug_captured() { |
| 13 | int x = 10; |
| 14 | |
| 15 | // Check both debug_captured counters, so we can do this all in one pass |
| 16 | // PGOGEN: store {{.*}} @[[DCC]], i64 0, i64 1 |
| 17 | // PGOUSE: br {{.*}} !prof ![[DC1:[0-9]+]] |
| 18 | // PGOGEN: store {{.*}} @[[DCC]], i64 0, i64 2 |
| 19 | // PGOUSE: br {{.*}} !prof ![[DC2:[0-9]+]] |
| 20 | // PGOALL: ret |
| 21 | |
| 22 | // PGOALL-LABEL: define internal void @__captured_stmt( |
| 23 | // PGOGEN: store {{.*}} @[[CSC]], i64 0, i64 0 |
| 24 | #pragma clang __debug captured |
| 25 | { |
| 26 | // PGOGEN: store {{.*}} @[[CSC]], i64 0, i64 1 |
| 27 | // PGOUSE: br {{.*}} !prof ![[CS1:[0-9]+]] |
| 28 | if (x) {} |
| 29 | // PGOALL: ret |
| 30 | } |
| 31 | |
| 32 | if (x) {} // This is DC1. Checked above. |
| 33 | |
| 34 | // PGOALL-LABEL: define internal void @__captured_stmt1( |
| 35 | // PGOGEN: store {{.*}} @[[C1C]], i64 0, i64 0 |
| 36 | #pragma clang __debug captured |
| 37 | { |
| 38 | // PGOGEN: store {{.*}} @[[C1C]], i64 0, i64 1 |
| 39 | // PGOUSE: br {{.*}} !prof ![[C11:[0-9]+]] |
| 40 | for (int i = 0; i < x; ++i) {} |
| 41 | // PGOGEN: store {{.*}} @[[C1C]], i64 0, i64 2 |
| 42 | // PGOUSE: br {{.*}} !prof ![[C12:[0-9]+]] |
| 43 | if (x) {} |
| 44 | // PGOALL: ret |
| 45 | } |
| 46 | |
| 47 | if (x) {} // This is DC2. Checked above. |
| 48 | } |
| 49 | |
| 50 | // PGOUSE-DAG: ![[DC1]] = metadata !{metadata !"branch_weights", i32 2, i32 1} |
| 51 | // PGOUSE-DAG: ![[DC2]] = metadata !{metadata !"branch_weights", i32 2, i32 1} |
| 52 | // PGOUSE-DAG: ![[CS1]] = metadata !{metadata !"branch_weights", i32 2, i32 1} |
| 53 | // PGOUSE-DAG: ![[C11]] = metadata !{metadata !"branch_weights", i32 11, i32 2} |
| 54 | // PGOUSE-DAG: ![[C12]] = metadata !{metadata !"branch_weights", i32 2, i32 1} |
| 55 | |
| 56 | int main(int argc, const char *argv[]) { |
| 57 | debug_captured(); |
| 58 | return 0; |
| 59 | } |