| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 1 | ;; Check that runtime symbols get appropriate linkage. |
| 2 | |
| Xinliang David Li | 7a88ad6 | 2015-10-29 04:08:31 +0000 | [diff] [blame] | 3 | ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s --check-prefix=OTHER --check-prefix=COMMON |
| 4 | ; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s --check-prefix=LINUX --check-prefix=COMMON |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 5 | |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 6 | @__profn_foo = hidden constant [3 x i8] c"foo" |
| 7 | @__profn_foo_weak = weak hidden constant [8 x i8] c"foo_weak" |
| 8 | @"__profn_linkage.ll:foo_internal" = internal constant [23 x i8] c"linkage.ll:foo_internal" |
| 9 | @__profn_foo_inline = linkonce_odr hidden constant [10 x i8] c"foo_inline" |
| Xinliang David Li | 985ff20 | 2016-02-27 23:11:30 +0000 | [diff] [blame^] | 10 | @__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern" |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 11 | |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 12 | ; COMMON: @__profc_foo = hidden global |
| 13 | ; COMMON: @__profd_foo = hidden global |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 14 | define void @foo() { |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 15 | call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0) |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 16 | ret void |
| 17 | } |
| 18 | |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 19 | ; COMMON: @__profc_foo_weak = weak hidden global |
| 20 | ; COMMON: @__profd_foo_weak = weak hidden global |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 21 | define weak void @foo_weak() { |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 22 | call void @llvm.instrprof.increment(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__profn_foo_weak, i32 0, i32 0), i64 0, i32 1, i32 0) |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 23 | ret void |
| 24 | } |
| 25 | |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 26 | ; COMMON: @"__profc_linkage.ll:foo_internal" = internal global |
| 27 | ; COMMON: @"__profd_linkage.ll:foo_internal" = internal global |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 28 | define internal void @foo_internal() { |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 29 | call void @llvm.instrprof.increment(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @"__profn_linkage.ll:foo_internal", i32 0, i32 0), i64 0, i32 1, i32 0) |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 30 | ret void |
| 31 | } |
| 32 | |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 33 | ; COMMON: @__profc_foo_inline = linkonce_odr hidden global |
| 34 | ; COMMON: @__profd_foo_inline = linkonce_odr hidden global |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 35 | define linkonce_odr void @foo_inline() { |
| Xinliang David Li | c7018a2 | 2015-12-15 00:32:56 +0000 | [diff] [blame] | 36 | call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_inline, i32 0, i32 0), i64 0, i32 1, i32 0) |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 37 | ret void |
| 38 | } |
| 39 | |
| Xinliang David Li | 985ff20 | 2016-02-27 23:11:30 +0000 | [diff] [blame^] | 40 | ; LINUX: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_cnts", comdat($__profv_foo_extern), align 8 |
| 41 | ; LINUX: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_data", comdat($__profv_foo_extern), align 8 |
| 42 | ; OTHER: @__profc_foo_extern = linkonce_odr hidden global |
| 43 | ; OTHER: @__profd_foo_extern = linkonce_odr hidden global |
| 44 | define available_externally void @foo_extern() { |
| 45 | call void @llvm.instrprof.increment(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @__profn_foo_extern, i32 0, i32 0), i64 0, i32 1, i32 0) |
| 46 | ret void |
| 47 | } |
| 48 | |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 49 | declare void @llvm.instrprof.increment(i8*, i64, i32, i32) |
| 50 | |
| Xinliang David Li | 7a88ad6 | 2015-10-29 04:08:31 +0000 | [diff] [blame] | 51 | ; OTHER: @__llvm_profile_runtime = external global i32 |
| 52 | ; LINUX-NOT: @__llvm_profile_runtime = external global i32 |
| Justin Bogner | 2ce4805 | 2015-02-24 21:42:42 +0000 | [diff] [blame] | 53 | |
| Xinliang David Li | 7a88ad6 | 2015-10-29 04:08:31 +0000 | [diff] [blame] | 54 | ; OTHER: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { |
| 55 | ; OTHER: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime |
| 56 | ; OTHER: ret i32 %[[REG]] |
| 57 | ; OTHER: } |
| 58 | ; LINUX-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { |
| 59 | ; LINUX-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime |