blob: 110838b1c8cbe27cf0624e7da9cf2bee60d4ff70 [file] [log] [blame]
Justin Bogner2ce48052015-02-24 21:42:42 +00001;; Check that runtime symbols get appropriate linkage.
2
Xinliang David Li7a88ad62015-10-29 04:08:31 +00003; 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 Bogner2ce48052015-02-24 21:42:42 +00005
Xinliang David Lic7018a22015-12-15 00:32:56 +00006@__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"
Justin Bogner2ce48052015-02-24 21:42:42 +000010
Xinliang David Lic7018a22015-12-15 00:32:56 +000011; COMMON: @__profc_foo = hidden global
12; COMMON: @__profd_foo = hidden global
Justin Bogner2ce48052015-02-24 21:42:42 +000013define void @foo() {
Xinliang David Lic7018a22015-12-15 00:32:56 +000014 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 Bogner2ce48052015-02-24 21:42:42 +000015 ret void
16}
17
Xinliang David Lic7018a22015-12-15 00:32:56 +000018; COMMON: @__profc_foo_weak = weak hidden global
19; COMMON: @__profd_foo_weak = weak hidden global
Justin Bogner2ce48052015-02-24 21:42:42 +000020define weak void @foo_weak() {
Xinliang David Lic7018a22015-12-15 00:32:56 +000021 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 Bogner2ce48052015-02-24 21:42:42 +000022 ret void
23}
24
Xinliang David Lic7018a22015-12-15 00:32:56 +000025; COMMON: @"__profc_linkage.ll:foo_internal" = internal global
26; COMMON: @"__profd_linkage.ll:foo_internal" = internal global
Justin Bogner2ce48052015-02-24 21:42:42 +000027define internal void @foo_internal() {
Xinliang David Lic7018a22015-12-15 00:32:56 +000028 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 Bogner2ce48052015-02-24 21:42:42 +000029 ret void
30}
31
Xinliang David Lic7018a22015-12-15 00:32:56 +000032; COMMON: @__profc_foo_inline = linkonce_odr hidden global
33; COMMON: @__profd_foo_inline = linkonce_odr hidden global
Justin Bogner2ce48052015-02-24 21:42:42 +000034define linkonce_odr void @foo_inline() {
Xinliang David Lic7018a22015-12-15 00:32:56 +000035 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 Bogner2ce48052015-02-24 21:42:42 +000036 ret void
37}
38
39declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
40
Xinliang David Li7a88ad62015-10-29 04:08:31 +000041; OTHER: @__llvm_profile_runtime = external global i32
42; LINUX-NOT: @__llvm_profile_runtime = external global i32
Justin Bogner2ce48052015-02-24 21:42:42 +000043
Xinliang David Li7a88ad62015-10-29 04:08:31 +000044; OTHER: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
45; OTHER: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
46; OTHER: ret i32 %[[REG]]
47; OTHER: }
48; LINUX-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
49; LINUX-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime