• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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=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-unknown-fuchsia -instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
6; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -instrprof -S | FileCheck %s --check-prefixes=COFF
7; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,MACHO
8; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
9; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
10; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
11
12; MACHO: @__llvm_profile_runtime = external global i32
13; LINUX-NOT: @__llvm_profile_runtime = external global i32
14
15@__profn_foo = hidden constant [3 x i8] c"foo"
16@__profn_foo_weak = weak hidden constant [8 x i8] c"foo_weak"
17@"__profn_linkage.ll:foo_internal" = internal constant [23 x i8] c"linkage.ll:foo_internal"
18@__profn_foo_inline = linkonce_odr hidden constant [10 x i8] c"foo_inline"
19@__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
20
21; POSIX: @__profc_foo = hidden global
22; POSIX: @__profd_foo = hidden global
23; COFF: @__profc_foo = internal global
24; COFF-NOT: comdat
25; COFF: @__profd_foo = internal global
26define void @foo() {
27  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)
28  ret void
29}
30
31; POSIX: @__profc_foo_weak = weak hidden global
32; POSIX: @__profd_foo_weak = weak hidden global
33; COFF: @__profc_foo_weak = internal global
34; COFF: @__profd_foo_weak = internal global
35define weak void @foo_weak() {
36  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)
37  ret void
38}
39
40; POSIX: @"__profc_linkage.ll:foo_internal" = internal global
41; POSIX: @"__profd_linkage.ll:foo_internal" = internal global
42; COFF: @"__profc_linkage.ll:foo_internal" = internal global
43; COFF: @"__profd_linkage.ll:foo_internal" = internal global
44define internal void @foo_internal() {
45  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)
46  ret void
47}
48
49; POSIX: @__profc_foo_inline = linkonce_odr hidden global
50; POSIX: @__profd_foo_inline = linkonce_odr hidden global
51; COFF: @__profc_foo_inline = internal global{{.*}} section ".lprfc$M", align 8
52; COFF: @__profd_foo_inline = internal global{{.*}} section ".lprfd$M", align 8
53define linkonce_odr void @foo_inline() {
54  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)
55  ret void
56}
57
58; LINUX: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_cnts", comdat($__profd_foo_extern), align 8
59; LINUX: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section "__llvm_prf_data", comdat, align 8
60; MACHO: @__profc_foo_extern = linkonce_odr hidden global
61; MACHO: @__profd_foo_extern = linkonce_odr hidden global
62; COFF: @__profc_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfc$M", comdat, align 8
63; COFF: @__profd_foo_extern = linkonce_odr hidden global {{.*}}section ".lprfd$M", comdat, align 8
64define available_externally void @foo_extern() {
65  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)
66  ret void
67}
68
69declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
70
71; MACHO: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
72; MACHO:   %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
73; MACHO:   ret i32 %[[REG]]
74; MACHO: }
75; COFF: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} comdat {
76; LINUX-NOT: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() {{.*}} {
77; LINUX-NOT:   %[[REG:.*]] = load i32, i32* @__llvm_profile_runtime
78