diff options
Diffstat (limited to 'test/Profile')
-rw-r--r-- | test/Profile/Inputs/c-captured.proftext | 2 | ||||
-rw-r--r-- | test/Profile/Inputs/cxx-rangefor.proftext | 13 | ||||
-rw-r--r-- | test/Profile/Inputs/cxx-throws.proftext | 12 | ||||
-rw-r--r-- | test/Profile/c-captured.c | 8 | ||||
-rw-r--r-- | test/Profile/c-general.c | 37 | ||||
-rw-r--r-- | test/Profile/c-generate.c | 10 | ||||
-rw-r--r-- | test/Profile/c-linkage-available_externally.c | 2 | ||||
-rw-r--r-- | test/Profile/c-linkage.c | 26 | ||||
-rw-r--r-- | test/Profile/c-unreachable-after-switch.c | 2 | ||||
-rw-r--r-- | test/Profile/cxx-lambda.cpp | 10 | ||||
-rw-r--r-- | test/Profile/cxx-linkage.cpp | 24 | ||||
-rw-r--r-- | test/Profile/cxx-rangefor.cpp | 44 | ||||
-rw-r--r-- | test/Profile/cxx-throws.cpp | 32 | ||||
-rw-r--r-- | test/Profile/cxx-virtual-destructor-calls.cpp | 30 | ||||
-rw-r--r-- | test/Profile/objc-general.m | 6 | ||||
-rw-r--r-- | test/Profile/profile-does-not-exist.c | 4 |
16 files changed, 187 insertions, 75 deletions
diff --git a/test/Profile/Inputs/c-captured.proftext b/test/Profile/Inputs/c-captured.proftext index c1baefc..a35e67b 100644 --- a/test/Profile/Inputs/c-captured.proftext +++ b/test/Profile/Inputs/c-captured.proftext @@ -4,7 +4,7 @@ c-captured.c:__captured_stmt 1 1 -c-captured.c:__captured_stmt1 +c-captured.c:__captured_stmt.1 266 3 1 diff --git a/test/Profile/Inputs/cxx-rangefor.proftext b/test/Profile/Inputs/cxx-rangefor.proftext new file mode 100644 index 0000000..7d2d1ef --- /dev/null +++ b/test/Profile/Inputs/cxx-rangefor.proftext @@ -0,0 +1,13 @@ +_Z9range_forv +0x000000000014a28a +5 +1 +4 +1 +1 +1 + +main +0 +1 +1 diff --git a/test/Profile/Inputs/cxx-throws.proftext b/test/Profile/Inputs/cxx-throws.proftext index 4016eca..1d197b9 100644 --- a/test/Profile/Inputs/cxx-throws.proftext +++ b/test/Profile/Inputs/cxx-throws.proftext @@ -11,8 +11,16 @@ _Z6throwsv 33 100 -main -0 +_Z11unreachablei +0x28a +3 1 1 +0 +main +0x2cc +3 +1 +1 +1 diff --git a/test/Profile/c-captured.c b/test/Profile/c-captured.c index 8a9e069..84fa6d3 100644 --- a/test/Profile/c-captured.c +++ b/test/Profile/c-captured.c @@ -3,9 +3,9 @@ // RUN: llvm-profdata merge %S/Inputs/c-captured.proftext -o %t.profdata // 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 -// PGOGEN: @[[DCC:__llvm_profile_counters_debug_captured]] = hidden global [3 x i64] zeroinitializer -// PGOGEN: @[[CSC:"__llvm_profile_counters_c-captured.c:__captured_stmt"]] = internal global [2 x i64] zeroinitializer -// PGOGEN: @[[C1C:"__llvm_profile_counters_c-captured.c:__captured_stmt1"]] = internal global [3 x i64] zeroinitializer +// PGOGEN: @[[DCC:__llvm_profile_counters_debug_captured]] = private global [3 x i64] zeroinitializer +// PGOGEN: @[[CSC:"__llvm_profile_counters_c-captured.c:__captured_stmt"]] = private global [2 x i64] zeroinitializer +// PGOGEN: @[[C1C:"__llvm_profile_counters_c-captured.c:__captured_stmt.1"]] = private global [3 x i64] zeroinitializer // PGOALL-LABEL: define void @debug_captured() // PGOGEN: store {{.*}} @[[DCC]], i64 0, i64 0 @@ -31,7 +31,7 @@ void debug_captured() { if (x) {} // This is DC1. Checked above. - // PGOALL-LABEL: define internal void @__captured_stmt1( + // PGOALL-LABEL: define internal void @__captured_stmt.1( // PGOGEN: store {{.*}} @[[C1C]], i64 0, i64 0 #pragma clang __debug captured { diff --git a/test/Profile/c-general.c b/test/Profile/c-general.c index 981fd98..4e123ae 100644 --- a/test/Profile/c-general.c +++ b/test/Profile/c-general.c @@ -8,17 +8,18 @@ // Also check compatibility with older profiles. // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%S/Inputs/c-general.profdata.v1 | FileCheck -check-prefix=PGOUSE %s -// PGOGEN: @[[SLC:__llvm_profile_counters_simple_loops]] = hidden global [4 x i64] zeroinitializer -// PGOGEN: @[[IFC:__llvm_profile_counters_conditionals]] = hidden global [11 x i64] zeroinitializer -// PGOGEN: @[[EEC:__llvm_profile_counters_early_exits]] = hidden global [9 x i64] zeroinitializer -// PGOGEN: @[[JMC:__llvm_profile_counters_jumps]] = hidden global [22 x i64] zeroinitializer -// PGOGEN: @[[SWC:__llvm_profile_counters_switches]] = hidden global [19 x i64] zeroinitializer -// PGOGEN: @[[BSC:__llvm_profile_counters_big_switch]] = hidden global [17 x i64] zeroinitializer -// PGOGEN: @[[BOC:__llvm_profile_counters_boolean_operators]] = hidden global [8 x i64] zeroinitializer -// PGOGEN: @[[BLC:__llvm_profile_counters_boolop_loops]] = hidden global [9 x i64] zeroinitializer -// PGOGEN: @[[COC:__llvm_profile_counters_conditional_operator]] = hidden global [3 x i64] zeroinitializer -// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = hidden global [1 x i64] zeroinitializer -// PGOGEN: @[[STC:"__llvm_profile_counters_c-general.c:static_func"]] = internal global [2 x i64] zeroinitializer +// PGOGEN: @[[SLC:__llvm_profile_counters_simple_loops]] = private global [4 x i64] zeroinitializer +// PGOGEN: @[[IFC:__llvm_profile_counters_conditionals]] = private global [11 x i64] zeroinitializer +// PGOGEN: @[[EEC:__llvm_profile_counters_early_exits]] = private global [9 x i64] zeroinitializer +// PGOGEN: @[[JMC:__llvm_profile_counters_jumps]] = private global [22 x i64] zeroinitializer +// PGOGEN: @[[SWC:__llvm_profile_counters_switches]] = private global [19 x i64] zeroinitializer +// PGOGEN: @[[BSC:__llvm_profile_counters_big_switch]] = private global [17 x i64] zeroinitializer +// PGOGEN: @[[BOC:__llvm_profile_counters_boolean_operators]] = private global [8 x i64] zeroinitializer +// PGOGEN: @[[BLC:__llvm_profile_counters_boolop_loops]] = private global [9 x i64] zeroinitializer +// PGOGEN: @[[COC:__llvm_profile_counters_conditional_operator]] = private global [3 x i64] zeroinitializer +// PGOGEN: @[[DFC:__llvm_profile_counters_do_fallthrough]] = private global [4 x i64] zeroinitializer +// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = private global [1 x i64] zeroinitializer +// PGOGEN: @[[STC:"__llvm_profile_counters_c-general.c:static_func"]] = private global [2 x i64] zeroinitializer // PGOGEN-LABEL: @simple_loops() // PGOUSE-LABEL: @simple_loops() @@ -436,15 +437,24 @@ void conditional_operator() { // PGOUSE-NOT: br {{.*}} !prof ![0-9]+ } +// PGOGEN-LABEL: @do_fallthrough() +// PGOUSE-LABEL: @do_fallthrough() +// PGOGEN: store {{.*}} @[[DFC]], i64 0, i64 0 void do_fallthrough() { + // PGOGEN: store {{.*}} @[[DFC]], i64 0, i64 1 + // PGOUSE: br {{.*}} !prof ![[DF1:[0-9]+]] for (int i = 0; i < 10; ++i) { int j = 0; + // PGOGEN: store {{.*}} @[[DFC]], i64 0, i64 2 do { // The number of exits out of this do-loop via the break statement // exceeds the counter value for the loop (which does not include the // fallthrough count). Make sure that does not violate any assertions. + // PGOGEN: store {{.*}} @[[DFC]], i64 0, i64 3 + // PGOUSE: br {{.*}} !prof ![[DF3:[0-9]+]] if (i < 8) break; j++; + // PGOUSE: br {{.*}} !prof ![[DF2:[0-9]+]] } while (j < 2); } } @@ -529,6 +539,11 @@ static void static_func() { // PGOUSE-DAG: ![[BL8]] = !{!"branch_weights", i32 51, i32 2} // PGOUSE-DAG: ![[CO1]] = !{!"branch_weights", i32 1, i32 2} // PGOUSE-DAG: ![[CO2]] = !{!"branch_weights", i32 2, i32 1} + +// PGOUSE-DAG: ![[DF1]] = !{!"branch_weights", i32 11, i32 2} +// PGOUSE-DAG: ![[DF2]] = !{!"branch_weights", i32 3, i32 3} +// PGOUSE-DAG: ![[DF3]] = !{!"branch_weights", i32 9, i32 5} + // PGOUSE-DAG: ![[ST1]] = !{!"branch_weights", i32 11, i32 2} int main(int argc, const char *argv[]) { diff --git a/test/Profile/c-generate.c b/test/Profile/c-generate.c new file mode 100644 index 0000000..8be4e28 --- /dev/null +++ b/test/Profile/c-generate.c @@ -0,0 +1,10 @@ +// Check that the -fprofile-instr-generate= form works. +// RUN: %clang_cc1 -main-file-name c-generate.c %s -o - -emit-llvm -fprofile-instr-generate=c-generate-test.profraw | FileCheck %s + +// CHECK: private constant [24 x i8] c"c-generate-test.profraw\00" +// CHECK: call void @__llvm_profile_override_default_filename(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @0, i32 0, i32 0)) +// CHECK: declare void @__llvm_profile_override_default_filename(i8*) + +int main(void) { + return 0; +} diff --git a/test/Profile/c-linkage-available_externally.c b/test/Profile/c-linkage-available_externally.c index e89632a..c2ff2ab 100644 --- a/test/Profile/c-linkage-available_externally.c +++ b/test/Profile/c-linkage-available_externally.c @@ -5,7 +5,7 @@ // CHECK: @__llvm_profile_name_foo = linkonce_odr hidden constant [3 x i8] c"foo", section "__DATA,__llvm_prf_names", align 1 // CHECK: @__llvm_profile_counters_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @__llvm_profile_data_foo = linkonce_odr hidden constant { i32, i32, i64, i8*, i64* } { i32 3, i32 1, i64 {{[0-9]+}}, i8* getelementptr inbounds ([3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64]* @__llvm_profile_counters_foo, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 +// CHECK: @__llvm_profile_data_foo = linkonce_odr hidden constant { i32, i32, i64, i8*, i64* } { i32 3, i32 1, i64 {{[0-9]+}}, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_profile_counters_foo, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 inline int foo(void) { return 1; } int main(void) { diff --git a/test/Profile/c-linkage.c b/test/Profile/c-linkage.c index 94393a4..9abbc29 100644 --- a/test/Profile/c-linkage.c +++ b/test/Profile/c-linkage.c @@ -1,22 +1,16 @@ -// Check the data structures emitted by instrumentation. +// Check that the profiling names we create have the linkage we expect // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s -// CHECK: @__llvm_profile_name_foo = hidden constant [3 x i8] c"foo", section "__DATA,__llvm_prf_names", align 1 -// CHECK: @__llvm_profile_name_foo_weak = weak hidden constant [8 x i8] c"foo_weak", section "__DATA,__llvm_prf_names", align 1 -// CHECK: @__llvm_profile_name_main = hidden constant [4 x i8] c"main", section "__DATA,__llvm_prf_names", align 1 -// CHECK: @"__llvm_profile_name_c-linkage.c:foo_internal" = internal constant [24 x i8] c"c-linkage.c:foo_internal", section "__DATA,__llvm_prf_names", align 1 +// CHECK: @__llvm_profile_name_foo = private constant [3 x i8] c"foo" +// CHECK: @__llvm_profile_name_foo_weak = weak hidden constant [8 x i8] c"foo_weak" +// CHECK: @__llvm_profile_name_main = private constant [4 x i8] c"main" +// CHECK: @"__llvm_profile_name_c-linkage.c:foo_internal" = private constant [24 x i8] c"c-linkage.c:foo_internal" -// CHECK: @__llvm_profile_counters_foo = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @__llvm_profile_data_foo = hidden constant { i32, i32, i64, i8*, i64* } { i32 3, i32 1, i64 {{[0-9]+}}, i8* getelementptr inbounds ([3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64]* @__llvm_profile_counters_foo, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 void foo(void) { } -// CHECK: @__llvm_profile_counters_foo_weak = weak hidden global [5 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @__llvm_profile_data_foo_weak = weak hidden constant { i32, i32, i64, i8*, i64* } { i32 8, i32 5, i64 {{[0-9]+}}, i8* getelementptr inbounds ([8 x i8]* @__llvm_profile_name_foo_weak, i32 0, i32 0), i64* getelementptr inbounds ([5 x i64]* @__llvm_profile_counters_foo_weak, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 void foo_weak(void) __attribute__((weak)); void foo_weak(void) { if (0){} if (0){} if (0){} if (0){} } -// CHECK: @__llvm_profile_counters_main = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @__llvm_profile_data_main = hidden constant { i32, i32, i64, i8*, i64* } { i32 4, i32 1, i64 {{[0-9]+}}, i8* getelementptr inbounds ([4 x i8]* @__llvm_profile_name_main, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64]* @__llvm_profile_counters_main, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 static void foo_internal(void); int main(void) { foo(); @@ -25,14 +19,4 @@ int main(void) { return 0; } -// CHECK: @"__llvm_profile_counters_c-linkage.c:foo_internal" = internal global [3 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @"__llvm_profile_data_c-linkage.c:foo_internal" = internal constant { i32, i32, i64, i8*, i64* } { i32 24, i32 3, i64 {{[0-9]+}}, i8* getelementptr inbounds ([24 x i8]* @"__llvm_profile_name_c-linkage.c:foo_internal", i32 0, i32 0), i64* getelementptr inbounds ([3 x i64]* @"__llvm_profile_counters_c-linkage.c:foo_internal", i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 static void foo_internal(void) { if (0){} if (0){} } - -// CHECK: @__llvm_profile_runtime = external global i32 -// CHECK: @llvm.used = appending global [5 x i8*] [i8* bitcast ({ i32, i32, i64, i8*, i64* }* @__llvm_profile_data_foo to i8*), i8* bitcast ({ i32, i32, i64, i8*, i64* }* @__llvm_profile_data_foo_weak to i8*), i8* bitcast ({ i32, i32, i64, i8*, i64* }* @__llvm_profile_data_main to i8*), i8* bitcast ({ i32, i32, i64, i8*, i64* }* @"__llvm_profile_data_c-linkage.c:foo_internal" to i8*), i8* bitcast (i32 ()* @__llvm_profile_runtime_user to i8*)], section "llvm.metadata" - -// CHECK: define linkonce_odr i32 @__llvm_profile_runtime_user() {{.*}} { -// CHECK: %[[REG:.*]] = load i32* @__llvm_profile_runtime -// CHECK: ret i32 %[[REG]] -// CHECK: } diff --git a/test/Profile/c-unreachable-after-switch.c b/test/Profile/c-unreachable-after-switch.c index 0770437..63add03 100644 --- a/test/Profile/c-unreachable-after-switch.c +++ b/test/Profile/c-unreachable-after-switch.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -O3 -triple x86_64-apple-macosx10.10 -main-file-name c-unreachable-after-switch.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s -// CHECK: @[[C:__llvm_profile_counters_foo]] = hidden global [3 x i64] zeroinitializer +// CHECK: @[[C:__llvm_profile_counters_foo]] = private global [3 x i64] zeroinitializer // CHECK-LABEL: @foo() // CHECK: store {{.*}} @[[C]], i64 0, i64 0 diff --git a/test/Profile/cxx-lambda.cpp b/test/Profile/cxx-lambda.cpp index ebf7f4c..34e1857 100644 --- a/test/Profile/cxx-lambda.cpp +++ b/test/Profile/cxx-lambda.cpp @@ -9,9 +9,9 @@ // RUN: FileCheck --input-file=%tuse -check-prefix=PGOUSE %s // RUN: FileCheck --input-file=%tuse -check-prefix=LMBUSE %s -// PGOGEN: @[[LWC:__llvm_profile_counters__Z7lambdasv]] = hidden global [4 x i64] zeroinitializer -// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = hidden global [1 x i64] zeroinitializer -// LMBGEN: @[[LFC:"__llvm_profile_counters_cxx-lambda.cpp:_ZZ7lambdasvENK3\$_0clEi"]] = internal global [3 x i64] zeroinitializer +// PGOGEN: @[[LWC:__llvm_profile_counters__Z7lambdasv]] = private global [4 x i64] zeroinitializer +// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = private global [1 x i64] zeroinitializer +// LMBGEN: @[[LFC:"__llvm_profile_counters_cxx-lambda.cpp:_ZZ7lambdasvENK3\$_0clEi"]] = private global [3 x i64] zeroinitializer // PGOGEN-LABEL: define void @_Z7lambdasv() // PGOUSE-LABEL: define void @_Z7lambdasv() @@ -19,8 +19,8 @@ void lambdas() { int i = 1; - // LMBGEN-LABEL: define internal{{( zeroext)?}} i1 @"_ZZ7lambdasvENK3$_0clEi"( - // LMBUSE-LABEL: define internal{{( zeroext)?}} i1 @"_ZZ7lambdasvENK3$_0clEi"( + // LMBGEN-LABEL: define internal{{( x86_thiscallcc)?( zeroext)?}} i1 @"_ZZ7lambdasvENK3$_0clEi"( + // LMBUSE-LABEL: define internal{{( x86_thiscallcc)?( zeroext)?}} i1 @"_ZZ7lambdasvENK3$_0clEi"( // LMBGEN: store {{.*}} @[[LFC]], i64 0, i64 0 auto f = [&i](int k) { // LMBGEN: store {{.*}} @[[LFC]], i64 0, i64 1 diff --git a/test/Profile/cxx-linkage.cpp b/test/Profile/cxx-linkage.cpp index e410218..669e8ed 100644 --- a/test/Profile/cxx-linkage.cpp +++ b/test/Profile/cxx-linkage.cpp @@ -1,21 +1,15 @@ // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -emit-llvm -main-file-name cxx-linkage.cpp %s -o - -fprofile-instr-generate | FileCheck %s -// CHECK: @__llvm_profile_name__Z3foov = hidden constant [7 x i8] c"_Z3foov", section "__DATA,__llvm_prf_names", align 1 -// CHECK: @__llvm_profile_name__Z8foo_weakv = weak hidden constant [12 x i8] c"_Z8foo_weakv", section "__DATA,__llvm_prf_names", align 1 -// CHECK: @__llvm_profile_name_main = hidden constant [4 x i8] c"main", section "__DATA,__llvm_prf_names", align 1 -// CHECK: @__llvm_profile_name__Z10foo_inlinev = linkonce_odr hidden constant [15 x i8] c"_Z10foo_inlinev", section "__DATA,__llvm_prf_names", align 1 +// CHECK: @__llvm_profile_name__Z3foov = private constant [7 x i8] c"_Z3foov" +// CHECK: @__llvm_profile_name__Z8foo_weakv = weak hidden constant [12 x i8] c"_Z8foo_weakv" +// CHECK: @__llvm_profile_name_main = private constant [4 x i8] c"main" +// CHECK: @__llvm_profile_name__Z10foo_inlinev = linkonce_odr hidden constant [15 x i8] c"_Z10foo_inlinev" -// CHECK: @__llvm_profile_counters__Z3foov = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @__llvm_profile_data__Z3foov = hidden constant { i32, i32, i64, i8*, i64* } { i32 7, i32 1, i64 {{[0-9]+}}, i8* getelementptr inbounds ([7 x i8]* @__llvm_profile_name__Z3foov, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64]* @__llvm_profile_counters__Z3foov, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 void foo(void) { } -// CHECK: @__llvm_profile_counters__Z8foo_weakv = weak hidden global [5 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @__llvm_profile_data__Z8foo_weakv = weak hidden constant { i32, i32, i64, i8*, i64* } { i32 12, i32 5, i64 {{[0-9]+}}, i8* getelementptr inbounds ([12 x i8]* @__llvm_profile_name__Z8foo_weakv, i32 0, i32 0), i64* getelementptr inbounds ([5 x i64]* @__llvm_profile_counters__Z8foo_weakv, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 void foo_weak(void) __attribute__((weak)); void foo_weak(void) { if (0){} if (0){} if (0){} if (0){} } -// CHECK: @__llvm_profile_counters_main = hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @__llvm_profile_data_main = hidden constant { i32, i32, i64, i8*, i64* } { i32 4, i32 1, i64 {{[0-9]+}}, i8* getelementptr inbounds ([4 x i8]* @__llvm_profile_name_main, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64]* @__llvm_profile_counters_main, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 inline void foo_inline(void); int main(void) { foo(); @@ -24,14 +18,4 @@ int main(void) { return 0; } -// CHECK: @__llvm_profile_counters__Z10foo_inlinev = linkonce_odr hidden global [7 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 -// CHECK: @__llvm_profile_data__Z10foo_inlinev = linkonce_odr hidden constant { i32, i32, i64, i8*, i64* } { i32 15, i32 7, i64 {{[0-9]+}}, i8* getelementptr inbounds ([15 x i8]* @__llvm_profile_name__Z10foo_inlinev, i32 0, i32 0), i64* getelementptr inbounds ([7 x i64]* @__llvm_profile_counters__Z10foo_inlinev, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8 inline void foo_inline(void) { if (0){} if (0){} if (0){} if (0){} if (0){} if (0){}} - -// CHECK: @__llvm_profile_runtime = external global i32 -// CHECK: @llvm.used = appending global [5 x i8*] [i8* bitcast ({ i32, i32, i64, i8*, i64* }* @__llvm_profile_data__Z3foov to i8*), i8* bitcast ({ i32, i32, i64, i8*, i64* }* @__llvm_profile_data__Z8foo_weakv to i8*), i8* bitcast ({ i32, i32, i64, i8*, i64* }* @__llvm_profile_data_main to i8*), i8* bitcast ({ i32, i32, i64, i8*, i64* }* @__llvm_profile_data__Z10foo_inlinev to i8*), i8* bitcast (i32 ()* @__llvm_profile_runtime_user to i8*)], section "llvm.metadata" - -// CHECK: define linkonce_odr i32 @__llvm_profile_runtime_user() {{.*}} { -// CHECK: %[[REG:.*]] = load i32* @__llvm_profile_runtime -// CHECK: ret i32 %[[REG]] -// CHECK: } diff --git a/test/Profile/cxx-rangefor.cpp b/test/Profile/cxx-rangefor.cpp new file mode 100644 index 0000000..f30cdc7 --- /dev/null +++ b/test/Profile/cxx-rangefor.cpp @@ -0,0 +1,44 @@ +// Tests for instrumentation of C++11 range-for + +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen +// RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s + +// RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse +// RUN: FileCheck --input-file=%tuse -check-prefix=CHECK -check-prefix=PGOUSE %s + +// PGOGEN: @[[RFC:__llvm_profile_counters__Z9range_forv]] = private global [5 x i64] zeroinitializer + +// CHECK-LABEL: define void @_Z9range_forv() +// PGOGEN: store {{.*}} @[[RFC]], i64 0, i64 0 +void range_for() { + int arr[] = {1, 2, 3, 4, 5}; + int sum = 0; + // PGOGEN: store {{.*}} @[[RFC]], i64 0, i64 1 + // PGOUSE: br {{.*}} !prof ![[RF1:[0-9]+]] + for (auto i : arr) { + // PGOGEN: store {{.*}} @[[RFC]], i64 0, i64 2 + // PGOUSE: br {{.*}} !prof ![[RF2:[0-9]+]] + if (i == 3) + continue; + sum += i; + // PGOGEN: store {{.*}} @[[RFC]], i64 0, i64 3 + // PGOUSE: br {{.*}} !prof ![[RF3:[0-9]+]] + if (sum >= 7) + break; + } + + // PGOGEN: store {{.*}} @[[RFC]], i64 0, i64 4 + // PGOUSE: br {{.*}} !prof ![[RF4:[0-9]+]] + if (sum) {} +} + +// PGOUSE-DAG: ![[RF1]] = !{!"branch_weights", i32 5, i32 1} +// PGOUSE-DAG: ![[RF2]] = !{!"branch_weights", i32 2, i32 4} +// PGOUSE-DAG: ![[RF3]] = !{!"branch_weights", i32 2, i32 3} +// PGOUSE-DAG: ![[RF4]] = !{!"branch_weights", i32 2, i32 1} + +int main(int argc, const char *argv[]) { + range_for(); + return 0; +} diff --git a/test/Profile/cxx-throws.cpp b/test/Profile/cxx-throws.cpp index e28b37d..47d079b 100644 --- a/test/Profile/cxx-throws.cpp +++ b/test/Profile/cxx-throws.cpp @@ -3,15 +3,16 @@ // FIXME: Don't seek bb labels, like "if.else" // REQUIRES: asserts -// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -target %itanium_abi_triple | FileCheck -check-prefix=PGOGEN %s -// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -target %itanium_abi_triple | FileCheck -check-prefix=PGOGEN-EXC %s +// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -fexceptions -target %itanium_abi_triple | FileCheck -check-prefix=PGOGEN %s +// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -fexceptions -target %itanium_abi_triple | FileCheck -check-prefix=PGOGEN-EXC %s // RUN: llvm-profdata merge %S/Inputs/cxx-throws.proftext -o %t.profdata -// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%t.profdata -target %itanium_abi_triple | FileCheck -check-prefix=PGOUSE %s -// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%t.profdata -target %itanium_abi_triple | FileCheck -check-prefix=PGOUSE-EXC %s +// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%t.profdata -fcxx-exceptions -target %itanium_abi_triple | FileCheck -check-prefix=PGOUSE %s +// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%t.profdata -fcxx-exceptions -target %itanium_abi_triple | FileCheck -check-prefix=PGOUSE-EXC %s -// PGOGEN: @[[THC:__llvm_profile_counters__Z6throwsv]] = hidden global [9 x i64] zeroinitializer -// PGOGEN-EXC: @[[THC:__llvm_profile_counters__Z6throwsv]] = hidden global [9 x i64] zeroinitializer +// PGOGEN: @[[THC:__llvm_profile_counters__Z6throwsv]] = private global [9 x i64] zeroinitializer +// PGOGEN-EXC: @[[THC:__llvm_profile_counters__Z6throwsv]] = private global [9 x i64] zeroinitializer +// PGOGEN: @[[UNC:__llvm_profile_counters__Z11unreachablei]] = private global [3 x i64] zeroinitializer // PGOGEN-LABEL: @_Z6throwsv() // PGOUSE-LABEL: @_Z6throwsv() @@ -60,14 +61,33 @@ void throws() { // PGOUSE: ret void } +// PGOGEN-LABEL: @_Z11unreachablei(i32 +// PGOUSE-LABEL: @_Z11unreachablei(i32 +// PGOGEN: store {{.*}} @[[UNC]], i64 0, i64 0 +void unreachable(int i) { + // PGOGEN: store {{.*}} @[[UNC]], i64 0, i64 1 + // PGOUSE: br {{.*}} !prof ![[UN1:[0-9]+]] + if (i) + throw i; + + // PGOGEN: store {{.*}} @[[UNC]], i64 0, i64 2 + // Since we never reach here, the weights should all be zero (and skipped) + // PGOUSE-NOT: br {{.*}} !prof !{{.*}} + if (i) {} +} + // PGOUSE-DAG: ![[TH1]] = !{!"branch_weights", i32 101, i32 2} // PGOUSE-DAG: ![[TH2]] = !{!"branch_weights", i32 67, i32 35} // PGOUSE-DAG: ![[TH3]] = !{!"branch_weights", i32 34, i32 34} // PGOUSE-DAG: ![[TH4]] = !{!"branch_weights", i32 18, i32 18} // PGOUSE-EXC: ![[TH5]] = !{!"branch_weights", i32 34, i32 18} // PGOUSE-DAG: ![[TH6]] = !{!"branch_weights", i32 101, i32 1} +// PGOUSE-DAG: ![[UN1]] = !{!"branch_weights", i32 2, i32 1} int main(int argc, const char *argv[]) { throws(); + try { + unreachable(1); + } catch (int) {} return 0; } diff --git a/test/Profile/cxx-virtual-destructor-calls.cpp b/test/Profile/cxx-virtual-destructor-calls.cpp new file mode 100644 index 0000000..35975c2 --- /dev/null +++ b/test/Profile/cxx-virtual-destructor-calls.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instr-generate | FileCheck %s + +struct Member { + ~Member(); +}; + +struct A { + virtual ~A(); +}; + +struct B : A { + Member m; + virtual ~B(); +}; + +// Complete dtor +// CHECK: @__llvm_profile_name__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev" + +// Deleting dtor +// CHECK: @__llvm_profile_name__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev" + +// Complete dtor counters and profile data +// CHECK: @__llvm_profile_counters__ZN1BD1Ev = private global [1 x i64] zeroinitializer +// CHECK: @__llvm_profile_data__ZN1BD1Ev = + +// Deleting dtor counters and profile data +// CHECK: @__llvm_profile_counters__ZN1BD0Ev = private global [1 x i64] zeroinitializer +// CHECK: @__llvm_profile_data__ZN1BD0Ev = + +B::~B() { } diff --git a/test/Profile/objc-general.m b/test/Profile/objc-general.m index 9a36667..eae1942 100644 --- a/test/Profile/objc-general.m +++ b/test/Profile/objc-general.m @@ -31,9 +31,9 @@ struct NSFastEnumerationState; @end; #endif -// PGOGEN: @[[FRC:"__llvm_profile_counters_objc-general.m:\+\[A foreach:\]"]] = internal global [2 x i64] zeroinitializer -// PGOGEN: @[[BLC:"__llvm_profile_counters_objc-general.m:__13\+\[A foreach:\]_block_invoke"]] = internal global [2 x i64] zeroinitializer -// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = hidden global [1 x i64] zeroinitializer +// PGOGEN: @[[FRC:"__llvm_profile_counters_objc-general.m:\+\[A foreach:\]"]] = private global [2 x i64] zeroinitializer +// PGOGEN: @[[BLC:"__llvm_profile_counters_objc-general.m:__13\+\[A foreach:\]_block_invoke"]] = private global [2 x i64] zeroinitializer +// PGOGEN: @[[MAC:__llvm_profile_counters_main]] = private global [1 x i64] zeroinitializer @interface A : NSObject + (void)foreach: (NSArray *)array; diff --git a/test/Profile/profile-does-not-exist.c b/test/Profile/profile-does-not-exist.c new file mode 100644 index 0000000..89609bd --- /dev/null +++ b/test/Profile/profile-does-not-exist.c @@ -0,0 +1,4 @@ +// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s + +// CHECK: error: Could not read profile: +// CHECK-NOT: Assertion failed |