blob: 6cbc88f3451905c7baa36d8f85a2d5be51710b23 [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
Xinliang David Lie6b89292016-04-18 17:47:38 +00005; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefix=OTHER --check-prefix=COMMON
6; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefix=LINUX --check-prefix=COMMON
Xinliang David Lif4edae62016-05-24 18:47:38 +00007; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s --check-prefix=COFF
8; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefix=COFF
Justin Bogner2ce48052015-02-24 21:42:42 +00009
Vedant Kumar9a041a72018-02-28 19:00:08 +000010; OTHER: @__llvm_profile_runtime = external global i32
11; LINUX-NOT: @__llvm_profile_runtime = external global i32
12
Xinliang David Lic7018a22015-12-15 00:32:56 +000013@__profn_foo = hidden constant [3 x i8] c"foo"
14@__profn_foo_weak = weak hidden constant [8 x i8] c"foo_weak"
15@"__profn_linkage.ll:foo_internal" = internal constant [23 x i8] c"linkage.ll:foo_internal"
16@__profn_foo_inline = linkonce_odr hidden constant [10 x i8] c"foo_inline"
Xinliang David Li985ff202016-02-27 23:11:30 +000017@__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
Justin Bogner2ce48052015-02-24 21:42:42 +000018
Xinliang David Lic7018a22015-12-15 00:32:56 +000019; COMMON: @__profc_foo = hidden global
20; COMMON: @__profd_foo = hidden global
Justin Bogner2ce48052015-02-24 21:42:42 +000021define void @foo() {
Xinliang David Lic7018a22015-12-15 00:32:56 +000022 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 +000023 ret void
24}
25
Xinliang David Lic7018a22015-12-15 00:32:56 +000026; COMMON: @__profc_foo_weak = weak hidden global
27; COMMON: @__profd_foo_weak = weak hidden global
Justin Bogner2ce48052015-02-24 21:42:42 +000028define weak void @foo_weak() {
Xinliang David Lic7018a22015-12-15 00:32:56 +000029 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 +000030 ret void
31}
32
Xinliang David Lic7018a22015-12-15 00:32:56 +000033; COMMON: @"__profc_linkage.ll:foo_internal" = internal global
34; COMMON: @"__profd_linkage.ll:foo_internal" = internal global
Reid Klecknerc6cf9182018-07-26 22:59:17 +000035; COFF: @"__profc_linkage.ll:foo_internal" = internal global
36; COFF: @"__profd_linkage.ll:foo_internal" = internal global
Justin Bogner2ce48052015-02-24 21:42:42 +000037define internal void @foo_internal() {
Xinliang David Lic7018a22015-12-15 00:32:56 +000038 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 +000039 ret void
40}
41
Xinliang David Lic7018a22015-12-15 00:32:56 +000042; COMMON: @__profc_foo_inline = linkonce_odr hidden global
43; COMMON: @__profd_foo_inline = linkonce_odr hidden global
Reid Klecknerc6cf9182018-07-26 22:59:17 +000044; FIXME: Should we put a comdat here?
45; COFF: @__profc_foo_inline = linkonce_odr hidden global {{.*}}section ".lprfc", align 8
46; COFF: @__profd_foo_inline = linkonce_odr hidden global {{.*}}section ".lprfd", align 8
Justin Bogner2ce48052015-02-24 21:42:42 +000047define linkonce_odr void @foo_inline() {
Xinliang David Lic7018a22015-12-15 00:32:56 +000048 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 +000049 ret void
50}
51
Xinliang David Li985ff202016-02-27 23:11:30 +000052; LINUX: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_cnts", comdat($__profv_foo_extern), align 8
53; LINUX: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_data", comdat($__profv_foo_extern), align 8
54; OTHER: @__profc_foo_extern = linkonce_odr hidden global
55; OTHER: @__profd_foo_extern = linkonce_odr hidden global
Reid Klecknerc6cf9182018-07-26 22:59:17 +000056; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfc", comdat, align 8
57; COFF: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfd", comdat($__profc_foo_extern), align 8
Xinliang David Li985ff202016-02-27 23:11:30 +000058define available_externally void @foo_extern() {
59 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)
60 ret void
61}
62
Justin Bogner2ce48052015-02-24 21:42:42 +000063declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
64
Xinliang David Li7a88ad62015-10-29 04:08:31 +000065; OTHER: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
66; OTHER: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
67; OTHER: ret i32 %[[REG]]
68; OTHER: }
Xinliang David Lif4edae62016-05-24 18:47:38 +000069; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat {
Xinliang David Li7a88ad62015-10-29 04:08:31 +000070; LINUX-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
71; LINUX-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime