1 ;; Check that runtime symbols get appropriate linkage.
3 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s --check-prefixes=POSIX,MACHO
4 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
5 ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s --check-prefixes=COFF
6 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,MACHO
7 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
8 ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
10 ; MACHO: @__llvm_profile_runtime = external global i32
11 ; LINUX-NOT: @__llvm_profile_runtime = external global i32
13 @__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"
17 @__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
19 ; POSIX: @__profc_foo = hidden global
20 ; POSIX: @__profd_foo = hidden global
21 ; COFF: @__profc_foo = internal global
23 ; COFF: @__profd_foo = internal global
25 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)
29 ; POSIX: @__profc_foo_weak = weak hidden global
30 ; POSIX: @__profd_foo_weak = weak hidden global
31 ; COFF: @__profc_foo_weak = internal global
32 ; COFF: @__profd_foo_weak = internal global
33 define weak void @foo_weak() {
34 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)
38 ; POSIX: @"__profc_linkage.ll:foo_internal" = internal global
39 ; POSIX: @"__profd_linkage.ll:foo_internal" = internal global
40 ; COFF: @"__profc_linkage.ll:foo_internal" = internal global
41 ; COFF: @"__profd_linkage.ll:foo_internal" = internal global
42 define internal void @foo_internal() {
43 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)
47 ; POSIX: @__profc_foo_inline = linkonce_odr hidden global
48 ; POSIX: @__profd_foo_inline = linkonce_odr hidden global
49 ; COFF: @__profc_foo_inline = internal global{{.*}} section ".lprfc$M", align 8
50 ; COFF: @__profd_foo_inline = internal global{{.*}} section ".lprfd$M", align 8
51 define linkonce_odr void @foo_inline() {
52 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)
56 ; LINUX: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_cnts", comdat($__profv_foo_extern), align 8
57 ; LINUX: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_data", comdat($__profv_foo_extern), align 8
58 ; MACHO: @__profc_foo_extern = linkonce_odr hidden global
59 ; MACHO: @__profd_foo_extern = linkonce_odr hidden global
60 ; COFF: @__profc_foo_extern = linkonce_odr dso_local global {{.*}}section ".lprfc$M", comdat, align 8
61 ; COFF: @__profd_foo_extern = internal global {{.*}}section ".lprfd$M", comdat($__profc_foo_extern), align 8
62 define available_externally void @foo_extern() {
63 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)
67 declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
69 ; MACHO: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
70 ; MACHO: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
71 ; MACHO: ret i32 %[[REG]]
73 ; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat {
74 ; LINUX-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
75 ; LINUX-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime