1 ;; Test runtime symbols and various linkages.
3 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=MACHO
4 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELFRT
5 ; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELFRT
6 ; RUN: opt < %s -mtriple=x86_64-scei-ps4 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS
7 ; RUN: opt < %s -mtriple=x86_64-sie-ps5 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,PS
8 ; RUN: opt < %s -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
9 ; RUN: opt < %s -mtriple=powerpc64-ibm-aix-xcoff -passes=instrprof -S | FileCheck %s --check-prefixes=XCOFF
10 ; RUN: opt < %s -mtriple=x86_64-pc-freebsd13 -passes=instrprof -S | FileCheck %s --check-prefixes=ELF
11 ; RUN: opt < %s -mtriple=wasm32-unknown-unknown -passes=instrprof -S | FileCheck %s --check-prefix=WASM
13 ; MACHO: @__llvm_profile_runtime = external hidden global i32
14 ; ELF-NOT: @__llvm_profile_runtime = external global i32
15 ; XCOFF-NOT: @__llvm_profile_runtime = external hidden global i32
16 ; COFF: @__llvm_profile_runtime = external hidden global i32
17 ; WASM: @__llvm_profile_runtime = external hidden global i32
19 ; ELF: $__profc_foo = comdat nodeduplicate
20 ; ELF: $__profc_foo_weak = comdat nodeduplicate
21 ; ELF: $"__profc_linkage.ll:foo_internal" = comdat nodeduplicate
22 ; ELF: $__profc_foo_inline = comdat nodeduplicate
23 ; ELF: $__profc_foo_extern = comdat any
25 @__profn_foo = private constant [3 x i8] c"foo"
26 @__profn_foo_weak = weak hidden constant [8 x i8] c"foo_weak"
27 @"__profn_linkage.ll:foo_internal" = private constant [23 x i8] c"linkage.ll:foo_internal"
28 @__profn_foo_inline = linkonce_odr hidden constant [10 x i8] c"foo_inline"
29 @__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
31 ; ELF: @__profc_foo = private global {{.*}} section "__llvm_prf_cnts", comdat
32 ; ELF: @__profd_foo = private global {{.*}} section "__llvm_prf_data", comdat($__profc_foo)
33 ; MACHO: @__profc_foo = private global
34 ; MACHO: @__profd_foo = private global
35 ; COFF: @__profc_foo = private global
37 ; COFF: @__profd_foo = private global
38 ; XCOFF: @__profc_foo = private global
40 ; XCOFF: @__profd_foo = private global
42 call void @llvm.instrprof.increment(ptr @__profn_foo, i64 0, i32 1, i32 0)
46 ; ELF: @__profc_foo_weak = weak hidden global{{.*}}section "__llvm_prf_cnts", comdat, align 8
47 ; ELF: @__profd_foo_weak = private global{{.*}}section "__llvm_prf_data", comdat($__profc_foo_weak)
48 ; MACHO: @__profc_foo_weak = weak hidden global
49 ; MACHO: @__profd_foo_weak = weak hidden global
50 ; COFF: @__profc_foo_weak = weak hidden global
51 ; COFF: @__profd_foo_weak = private global
52 ; XCOFF: @__profc_foo_weak = private global
53 ; XCOFF: @__profd_foo_weak = private global
54 define weak void @foo_weak() {
55 call void @llvm.instrprof.increment(ptr @__profn_foo_weak, i64 0, i32 1, i32 0)
59 ; ELF: @"__profc_linkage.ll:foo_internal" = private global{{.*}}section "__llvm_prf_cnts", comdat, align 8
60 ; ELF: @"__profd_linkage.ll:foo_internal" = private global{{.*}}section "__llvm_prf_data", comdat($"__profc_linkage.ll:foo_internal"), align 8
61 ; MACHO: @"__profc_linkage.ll:foo_internal" = private global
62 ; MACHO: @"__profd_linkage.ll:foo_internal" = private global
63 ; COFF: @"__profc_linkage.ll:foo_internal" = private global
64 ; COFF: @"__profd_linkage.ll:foo_internal" = private global
65 ; XCOFF: @"__profc_linkage.ll:foo_internal" = private global
66 ; XCOFF: @"__profd_linkage.ll:foo_internal" = private global
67 define internal void @foo_internal() {
68 call void @llvm.instrprof.increment(ptr @"__profn_linkage.ll:foo_internal", i64 0, i32 1, i32 0)
72 ; ELF: @__profc_foo_inline = linkonce_odr hidden global{{.*}}section "__llvm_prf_cnts", comdat, align 8
73 ; ELF: @__profd_foo_inline = private global{{.*}}section "__llvm_prf_data", comdat($__profc_foo_inline), align 8
74 ; MACHO: @__profc_foo_inline = linkonce_odr hidden global
75 ; MACHO: @__profd_foo_inline = linkonce_odr hidden global
76 ; COFF: @__profc_foo_inline = linkonce_odr hidden global{{.*}} section ".lprfc$M", align 8
77 ; COFF: @__profd_foo_inline = private global{{.*}} section ".lprfd$M", align 8
78 ; XCOFF: @__profc_foo_inline = private global
79 ; XCOFF: @__profd_foo_inline = private global
80 define linkonce_odr void @foo_inline() {
81 call void @llvm.instrprof.increment(ptr @__profn_foo_inline, i64 0, i32 1, i32 0)
85 ; ELF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_cnts", comdat, align 8
86 ; ELF: @__profd_foo_extern = private global {{.*}}section "__llvm_prf_data", comdat($__profc_foo_extern), align 8
87 ; MACHO: @__profc_foo_extern = linkonce_odr hidden global
88 ; MACHO: @__profd_foo_extern = linkonce_odr hidden global
89 ; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfc$M", comdat, align 8
90 ; COFF: @__profd_foo_extern = internal global {{.*}}section ".lprfd$M", comdat($__profc_foo_extern), align 8
91 ; XCOFF: @__profc_foo_extern = private global
92 ; XCOFF: @__profd_foo_extern = private global
93 define available_externally void @foo_extern() {
94 call void @llvm.instrprof.increment(ptr @__profn_foo_extern, i64 0, i32 1, i32 0)
98 declare void @llvm.instrprof.increment(ptr, i64, i32, i32)
100 ; ELF: @llvm.compiler.used = appending global {{.*}} [{{.*}}ptr @__profd_foo, ptr @__profd_foo_weak, ptr @"__profd_linkage.ll:foo_internal", ptr @__profd_foo_inline, ptr @__profd_foo_extern{{.*}}]
101 ; MACHO: @llvm.compiler.used = appending global [6 x ptr] [ptr @__llvm_profile_runtime_user, ptr @__profd_foo, {{.*}}
102 ; COFF: @llvm.compiler.used = appending global [6 x ptr] [ptr @__llvm_profile_runtime_user, ptr @__profd_foo, ptr @__profd_foo_weak, ptr @"__profd_linkage.ll:foo_internal", ptr @__profd_foo_inline, ptr @__profd_foo_extern]
103 ; XCOFF: @llvm.used = appending global [6 x ptr] [ptr @__profd_foo, ptr @__profd_foo_weak, ptr @"__profd_linkage.ll:foo_internal", ptr @__profd_foo_inline, ptr @__profd_foo_extern, ptr @__llvm_prf_nm]
104 ; WASM: @llvm.used = appending global [7 x ptr] [ptr @__llvm_profile_runtime_user, ptr @__profd_foo, ptr @__profd_foo_weak, ptr @"__profd_linkage.ll:foo_internal", ptr @__profd_foo_inline, ptr @__profd_foo_extern, ptr @__llvm_prf_nm]
106 ; MACHO: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
107 ; MACHO: %[[REG:.*]] = load i32, ptr @__llvm_profile_runtime
108 ; MACHO: ret i32 %[[REG]]
110 ; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat {
111 ; ELFRT-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
112 ; ELFRT-NOT: %[[REG:.*]] = load i32, ptr @__llvm_profile_runtime
113 ; PS: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
114 ; PS: %[[REG:.*]] = load i32, ptr @__llvm_profile_runtime
115 ; XCOFF-NOT: define .* __llvm_profile_runtime_user
117 ; WASM-NOT: internal void @__llvm_profile_register_functions()
119 ; XCOFF-NOT: internal void @__llvm_profile_register_functions()