1;; Checks for platform specific section names and initialization code.
2
3; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | FileCheck %s -check-prefix=MACHO
4; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | FileCheck %s -check-prefix=MACHO
5; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -S | FileCheck %s -check-prefixes=LINUX,ELF
6; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s -check-prefixes=LINUX,ELF
7; RUN: opt < %s -mtriple=x86_64-unknown-freebsd -instrprof -S | FileCheck %s -check-prefixes=FREEBSD,ELF
8; RUN: opt < %s -mtriple=x86_64-unknown-freebsd -passes=instrprof -S | FileCheck %s -check-prefixes=FREEBSD,ELF
9; RUN: opt < %s -mtriple=x86_64-scei-ps4 -instrprof -S | FileCheck %s -check-prefixes=PS4,ELF
10; RUN: opt < %s -mtriple=x86_64-scei-ps4 -passes=instrprof -S | FileCheck %s -check-prefixes=PS4,ELF
11; RUN: opt < %s -mtriple=x86_64-pc-solaris -instrprof -S | FileCheck %s -check-prefixes=SOLARIS,ELF
12; RUN: opt < %s -mtriple=x86_64-pc-solaris -passes=instrprof -S | FileCheck %s -check-prefixes=SOLARIS,ELF
13; RUN: opt < %s -mtriple=x86_64-pc-windows -instrprof -S | FileCheck %s -check-prefix=WINDOWS
14; RUN: opt < %s -mtriple=x86_64-pc-windows -passes=instrprof -S | FileCheck %s -check-prefix=WINDOWS
15; RUN: opt < %s -mtriple=powerpc64-ibm-aix-xcoff -passes=instrprof -S | FileCheck %s -check-prefix=AIX
16
17@__profn_foo = private constant [3 x i8] c"foo"
18; MACHO-NOT: __profn_foo
19; ELF-NOT: __profn_foo
20; WINDOWS-NOT: __profn_foo
21; AIX-NOT: __profn_foo
22
23; MACHO: @__profc_foo = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
24; ELF: @__profc_foo = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8
25; WINDOWS: @__profc_foo = private global [1 x i64] zeroinitializer, section ".lprfc$M", align 8
26; AIX: @__profc_foo = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
27
28; MACHO: @__profd_foo = private {{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
29; ELF: @__profd_foo = private {{.*}}, section "__llvm_prf_data", comdat($__profc_foo), align 8
30; WINDOWS: @__profd_foo = private global {{.*}}, section ".lprfd$M", align 8
31; AIX: @__profd_foo = private {{.*}}, section "__llvm_prf_data", align 8
32
33; ELF: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names", align 1
34; WINDOWS: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}lprfn$M", align 1
35; AIX: @__llvm_prf_nm = private constant [{{.*}} x i8] c"{{.*}}", section "{{.*}}__llvm_prf_names", align 1
36
37define void @foo() {
38  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)
39  ret void
40}
41
42declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
43
44;; Emit registration functions for platforms that don't find the
45;; symbols by their sections.
46
47; MACHO-NOT: define internal void @__llvm_profile_register_functions
48; LINUX-NOT: define internal void @__llvm_profile_register_functions
49; FREEBSD-NOT: define internal void @__llvm_profile_register_functions
50; SOLARIS-NOT: define internal void @__llvm_profile_register_functions
51; PS4-NOT: define internal void @__llvm_profile_register_functions
52; WINDOWS-NOT: define internal void @__llvm_profile_register_functions
53; AIX: define internal void @__llvm_profile_register_functions
54
55;; PR38340: When dynamic registration is used, we had a bug where we'd register
56;; something that's not a __profd_* variable.
57
58; MACHO-NOT: define internal void @__llvm_profile_init
59; LINUX-NOT: define internal void @__llvm_profile_init
60; FREEBSD-NOT: define internal void @__llvm_profile_init
61; SOLARIS-NOT: define internal void @__llvm_profile_init
62; PS4-NOT: define internal void @__llvm_profile_init
63; WINDOWS-NOT: define internal void @__llvm_profile_init
64; AIX: define internal void @__llvm_profile_init
65