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