1;; Check that runtime symbols get appropriate linkage. 2 3; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s --check-prefixes=COMMON,MACHO 4; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s --check-prefixes=COMMON,LINUX 5; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s --check-prefixes=COMMON,COFF 6; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=COMMON,MACHO 7; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=COMMON,LINUX 8; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COMMON,COFF 9 10; MACHO: @__llvm_profile_runtime = external global i32 11; LINUX-NOT: @__llvm_profile_runtime = external global i32 12 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" 18 19; COMMON: @__profc_foo = hidden global 20; COMMON: @__profd_foo = hidden global 21define void @foo() { 22 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) 23 ret void 24} 25 26; COMMON: @__profc_foo_weak = weak hidden global 27; COMMON: @__profd_foo_weak = weak hidden global 28define weak void @foo_weak() { 29 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) 30 ret void 31} 32 33; COMMON: @"__profc_linkage.ll:foo_internal" = internal global 34; COMMON: @"__profd_linkage.ll:foo_internal" = internal global 35define internal void @foo_internal() { 36 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) 37 ret void 38} 39 40; COMMON: @__profc_foo_inline = linkonce_odr hidden global 41; COFF-SAME: section ".lprfc", align 8 42; COMMON: @__profd_foo_inline = linkonce_odr hidden global 43; COFF-SAME: section ".lprfd", align 8 44define linkonce_odr void @foo_inline() { 45 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) 46 ret void 47} 48 49; LINUX: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_cnts", comdat($__profv_foo_extern), align 8 50; LINUX: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_data", comdat($__profv_foo_extern), align 8 51; MACHO: @__profc_foo_extern = linkonce_odr hidden global 52; MACHO: @__profd_foo_extern = linkonce_odr hidden global 53; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfc", comdat, align 8 54; COFF: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfd", comdat($__profc_foo_extern), align 8 55define available_externally void @foo_extern() { 56 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) 57 ret void 58} 59 60declare void @llvm.instrprof.increment(i8*, i64, i32, i32) 61 62; MACHO: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { 63; MACHO: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime 64; MACHO: ret i32 %[[REG]] 65; MACHO: } 66; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat { 67; LINUX-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} { 68; LINUX-NOT: %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime 69