diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-28 17:53:22 +0000 | 
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-28 17:53:22 +0000 | 
| commit | d971cd1b181557eaac297410ce809dcdf441f211 (patch) | |
| tree | 9c4c9aa5fc3c59d8f7ed37d734803d44aa4e137f /clang/test | |
| parent | 2d8f93e8692d743a17c737a5376b2051ad303320 (diff) | |
| download | bcm5719-llvm-d971cd1b181557eaac297410ce809dcdf441f211.tar.gz bcm5719-llvm-d971cd1b181557eaac297410ce809dcdf441f211.zip | |
InstrProf: Emit runtime hook directly in IRGen
-u behaviour is apparently not portable between linkers (see cfe-commits
discussions for r204379 and r205012).  I've moved the logic to IRGen,
where it should have been in the first place.
I don't have a Linux system to test this on, so it's possible this logic
*still* doesn't pull in the instrumented profiling runtime on Linux.
I'm in the process of getting tests going on the compiler-rt side
(llvm-commits "[PATCH] InstrProf: Add initial compiler-rt test").  Once
we have tests for the full flow there, the runtime logic should get a
whole lot less brittle.
<rdar://problem/16458307>
llvm-svn: 205023
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Profile/c-linkage.c | 8 | ||||
| -rw-r--r-- | clang/test/Profile/cxx-linkage.cpp | 8 | 
2 files changed, 14 insertions, 2 deletions
| diff --git a/clang/test/Profile/c-linkage.c b/clang/test/Profile/c-linkage.c index a688197d494..72eae1f0f32 100644 --- a/clang/test/Profile/c-linkage.c +++ b/clang/test/Profile/c-linkage.c @@ -1,6 +1,7 @@  // Check the data structures emitted by instrumentation.  // 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_runtime = external global i32  // CHECK: @__llvm_profile_counters_foo = global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8  // CHECK: @__llvm_profile_name_foo = constant [3 x i8] c"foo", section "__DATA,__llvm_prf_names", align 1  // CHECK: @__llvm_profile_data_foo = constant { i32, i32, i64, i8*, i64* } { i32 3, i32 1, i64 1, 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 @@ -28,4 +29,9 @@ int main(void) {  // CHECK: @__llvm_profile_data_foo_internal = internal constant { i32, i32, i64, i8*, i64* } { i32 24, i32 3, i64 3, i8* getelementptr inbounds ([24 x i8]* @__llvm_profile_name_foo_internal, i32 0, i32 0), i64* getelementptr inbounds ([3 x i64]* @__llvm_profile_counters_foo_internal, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8  static void foo_internal(void) { if (0){} if (0){} } -// CHECK: @llvm.used = appending global [4 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_foo_internal to i8*)], section "llvm.metadata" +// CHECK: @llvm.used = appending global [5 x i8*] [i8* bitcast (i32 ()* @__llvm_profile_runtime_user to 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_foo_internal 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/clang/test/Profile/cxx-linkage.cpp b/clang/test/Profile/cxx-linkage.cpp index 16f84a68b02..44c1983c849 100644 --- a/clang/test/Profile/cxx-linkage.cpp +++ b/clang/test/Profile/cxx-linkage.cpp @@ -1,5 +1,6 @@  // 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_runtime = external global i32  // CHECK: @__llvm_profile_counters__Z3foov = global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8  // CHECK: @__llvm_profile_name__Z3foov = constant [7 x i8] c"_Z3foov", section "__DATA,__llvm_prf_names", align 1  // CHECK: @__llvm_profile_data__Z3foov = constant { i32, i32, i64, i8*, i64* } { i32 7, i32 1, i64 1, 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 @@ -27,4 +28,9 @@ int main(void) {  // CHECK: @__llvm_profile_data__Z10foo_inlinev = linkonce_odr constant { i32, i32, i64, i8*, i64* } { i32 15, i32 7, i64 7, 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.used = appending global [4 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*)], section "llvm.metadata" +// CHECK: @llvm.used = appending global [5 x i8*] [i8* bitcast (i32 ()* @__llvm_profile_runtime_user to 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*)], section "llvm.metadata" + +// CHECK: define linkonce_odr i32 @__llvm_profile_runtime_user() {{.*}} { +// CHECK:   %[[REG:.*]] = load i32* @__llvm_profile_runtime +// CHECK:   ret i32 %[[REG]] +// CHECK: } | 

