1 ; RUN: rm -rf %t && split-file %s %t
3 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
4 ; RUN: -xcoff-traceback-table=false < %t/no-ref.ll | FileCheck %s --check-prefixes=NOREF
5 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
6 ; RUN: -xcoff-traceback-table=false --filetype=obj < %t/no-ref.ll -o %t/no-ref.o
7 ; RUN: llvm-objdump %t/no-ref.o -r | FileCheck %s --check-prefix=NOREF-OBJ
9 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
10 ; RUN: -xcoff-traceback-table=false < %t/no-vnds.ll | FileCheck %s --check-prefixes=NOVNDS
11 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
12 ; RUN: -xcoff-traceback-table=false --filetype=obj < %t/no-vnds.ll -o %t/no-vnds.o
13 ; RUN: llvm-objdump %t/no-vnds.o -r | FileCheck %s --check-prefix=NOVNDS-OBJ
15 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
16 ; RUN: -xcoff-traceback-table=false < %t/with-vnds.ll | FileCheck %s --check-prefixes=WITHVNDS
17 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
18 ; RUN: -xcoff-traceback-table=false --filetype=obj < %t/with-vnds.ll -o %t/with-vnds.o
19 ; RUN: llvm-objdump %t/with-vnds.o -tr | FileCheck %s --check-prefix=WITHVNDS-OBJ
21 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
22 ; RUN: -xcoff-traceback-table=false < %t/zero-size-cnts-section.ll | FileCheck %s --check-prefixes=ZERO-SIZE-CNTS
23 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
24 ; RUN: -xcoff-traceback-table=false --filetype=obj < %t/zero-size-cnts-section.ll -o %t/zero-size-cnts-section.o
25 ; RUN: llvm-objdump %t/zero-size-cnts-section.o -tr | FileCheck %s --check-prefix=ZERO-SIZE-CNTS-OBJ
27 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
28 ; RUN: -xcoff-traceback-table=false < %t/zero-size-other-section.ll | FileCheck %s --check-prefixes=ZERO-SIZE-OTHER
29 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc64-ibm-aix-xcoff \
30 ; RUN: -xcoff-traceback-table=false < %t/zero-size-other-section.ll | FileCheck %s --check-prefixes=ZERO-SIZE-OTHER
31 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff \
32 ; RUN: -xcoff-traceback-table=false --filetype=obj < %t/zero-size-other-section.ll -o %t/zero-size-other-section.o
33 ; RUN: llvm-objdump %t/zero-size-other-section.o -tr | FileCheck %s --check-prefix=ZERO-SIZE-OTHER-OBJ
34 ; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc64-ibm-aix-xcoff \
35 ; RUN: -xcoff-traceback-table=false --filetype=obj < %t/zero-size-other-section.ll -o %t/zero-size-other-section.o
36 ; RUN: llvm-objdump %t/zero-size-other-section.o -tr | FileCheck %s --check-prefix=ZERO-SIZE-OTHER-OBJ
40 ; The absence of a __llvm_prf_cnts section should stop generating the .refs.
42 target datalayout = "E-m:a-p:32:32-i64:64-n32"
43 target triple = "powerpc-ibm-aix7.2.0.0"
45 @__profd_main = private global i64 zeroinitializer, section "__llvm_prf_data", align 8
46 @__llvm_prf_nm = private constant [6 x i8] c"\04\00main", section "__llvm_prf_names", align 1
48 @llvm.used = appending global [2 x ptr]
50 ptr @__llvm_prf_nm], section "llvm.metadata"
52 define i32 @main() #0 {
57 ; NOREF-NOT: .ref __llvm_prf_data
58 ; NOREF-NOT: .ref __llvm_prf_names
59 ; NOREF-NOT: .ref __llvm_prf_vnds
61 ; NOREF-OBJ-NOT: R_REF __llvm_prf_data
62 ; NOREF-OBJ-NOT: R_REF __llvm_prf_names
63 ; NOREF-OBJ-NOT: R_REF __llvm_prf_vnds
66 ; This is the most common case. When -fprofile-generate is used and there exists executable code, we generate the __llvm_prf_cnts, __llvm_prf_data, and __llvm_prf_names sections.
68 target datalayout = "E-m:a-p:32:32-i64:64-n32"
69 target triple = "powerpc-ibm-aix7.2.0.0"
71 @__profc_main = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
72 @__profd_main = private global i64 zeroinitializer, section "__llvm_prf_data", align 8
73 @__llvm_prf_nm = private constant [6 x i8] c"\04\00main", section "__llvm_prf_names", align 1
75 @llvm.used = appending global [3 x ptr]
78 ptr @__llvm_prf_nm], section "llvm.metadata"
80 define i32 @main() #0 {
84 ; There will be two __llvm_prf_cnts .csects, one to represent the actual csect
85 ; that holds @__profc_main, and one generated to hold the .ref directives. In
86 ; XCOFF, a csect can be defined in pieces, so this is is legal assembly.
88 ; NOVNDS: .csect __llvm_prf_cnts[RW],3
89 ; NOVNDS: .csect __llvm_prf_cnts[RW],3
90 ; NOVNDS-NEXT: .ref __llvm_prf_data[RW]
91 ; NOVNDS-NEXT: .ref __llvm_prf_names[RO]
92 ; NOVNDS-NOT: .ref __llvm_prf_vnds
94 ; NOVNDS-OBJ: 00000000 R_REF __llvm_prf_data
95 ; NOVNDS-OBJ: 00000000 R_REF __llvm_prf_names
96 ; NOVNDS-OBJ-NOT: R_REF __llvm_prf_vnds
99 ; When value profiling is needed, the PGO instrumentation generates variables in the __llvm_prf_vnds section, so we generate a .ref for them too.
101 @__profc_main = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
102 @__profd_main = private global i64 zeroinitializer, section "__llvm_prf_data", align 8
103 @__llvm_prf_nm = private constant [6 x i8] c"\04\00main", section "__llvm_prf_names", align 1
104 @__llvm_prf_vnodes = private global [10 x { i64, i64, ptr }] zeroinitializer, section "__llvm_prf_vnds"
106 @llvm.used = appending global [4 x ptr]
110 ptr @__llvm_prf_vnodes], section "llvm.metadata"
112 define i32 @main() #0 {
117 ; WITHVNDS: .csect __llvm_prf_cnts[RW],3
118 ; WITHVNDS: .csect __llvm_prf_cnts[RW],3
119 ; WITHVNDS-NEXT: .ref __llvm_prf_data[RW]
120 ; WITHVNDS-NEXT: .ref __llvm_prf_names[RO]
121 ; WITHVNDS-NEXT: .ref __llvm_prf_vnds[RW]
123 ; WITHVNDS-OBJ: SYMBOL TABLE:
124 ; WITHVNDS-OBJ-NEXT: 00000000 df *DEBUG* 00000000 .file
125 ; WITHVNDS-OBJ-NEXT: 00000000 l .text 00000008
126 ; WITHVNDS-OBJ-NEXT: 00000000 g F .text (csect: ) 00000000 .main
127 ; WITHVNDS-OBJ-NEXT: 00000008 l .text 00000006 __llvm_prf_names
128 ; WITHVNDS-OBJ-NEXT: 00000010 l O .data 00000008 __llvm_prf_cnts
129 ; WITHVNDS-OBJ-NEXT: 00000018 l O .data 00000008 __llvm_prf_data
130 ; WITHVNDS-OBJ-NEXT: 00000020 l O .data 000000f0 __llvm_prf_vnds
131 ; WITHVNDS-OBJ-NEXT: 00000110 g O .data 0000000c main
132 ; WITHVNDS-OBJ-NEXT: 0000011c l .data 00000000 TOC
134 ; WITHVNDS-OBJ: RELOCATION RECORDS FOR [.data]:
135 ; WITHVNDS-OBJ-NEXT: OFFSET TYPE VALUE
136 ; WITHVNDS-OBJ-NEXT: 00000000 R_REF __llvm_prf_data
137 ; WITHVNDS-OBJ-NEXT: 00000000 R_REF __llvm_prf_names
138 ; WITHVNDS-OBJ-NEXT: 00000000 R_REF __llvm_prf_vnds
139 ; WITHVNDS-OBJ-NEXT: 00000100 R_POS .main
140 ; WITHVNDS-OBJ-NEXT: 00000104 R_POS TOC
142 ;--- zero-size-cnts-section.ll
143 ; If __llvm_prf_cnts is of zero size, do not generate the .ref directive.
144 ; The size of the other sections does not matter.
146 @dummy_cnts = private global [0 x i32] zeroinitializer, section "__llvm_prf_cnts", align 4
147 @dummy_data = private global [1 x i64] zeroinitializer, section "__llvm_prf_data", align 8
148 @dummy_name = private constant [0 x i32] zeroinitializer, section "__llvm_prf_names", align 4
150 @llvm.used = appending global [3 x ptr]
153 ptr @dummy_name], section "llvm.metadata"
155 define i32 @main() #0 {
160 ; ZERO-SIZE-CNTS-NOT: .ref __llvm_prf_data[RW]
161 ; ZERO-SIZE-CNTS-NOT: .ref __llvm_prf_names[RO]
162 ; ZERO-SIZE-CNTS-NOT: .ref __llvm_prf_vnds
164 ; ZERO-SIZE-CNTS-OBJ-NOT: R_REF __llvm_prf_data
165 ; ZERO-SIZE-CNTS-OBJ-NOT: R_REF __llvm_prf_names
166 ; ZERO-SIZE-CNTS-OBJ-NOT: R_REF __llvm_prf_vnds
168 ;--- zero-size-other-section.ll
169 ; If __llvm_prf_cnts is of non-zero size, generate the .ref directive even if other sections
172 @__profc_main = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
173 @__profd_main = private global [0 x i64] zeroinitializer, section "__llvm_prf_data", align 8
174 @__llvm_prf_nm = private constant [0 x i8] zeroinitializer, section "__llvm_prf_names", align 1
175 @__llvm_prf_vnodes = private global [0 x { i64, i64, ptr }] zeroinitializer, section "__llvm_prf_vnds"
177 @llvm.used = appending global [4 x ptr]
181 ptr @__llvm_prf_vnodes], section "llvm.metadata"
183 define i32 @main() #0 {
188 ; ZERO-SIZE-OTHER: .csect __llvm_prf_cnts[RW],3
189 ; ZERO-SIZE-OTHER: .csect __llvm_prf_cnts[RW],3
190 ; ZERO-SIZE-OTHER-NEXT: .ref __llvm_prf_data[RW]
191 ; ZERO-SIZE-OTHER-NEXT: .ref __llvm_prf_names[RO]
192 ; ZERO-SIZE-OTHER-NEXT: .ref __llvm_prf_vnds[RW]
194 ; ZERO-SIZE-OTHER-OBJ: R_REF __llvm_prf_data
195 ; ZERO-SIZE-OTHER-OBJ-NEXT: R_REF __llvm_prf_names
196 ; ZERO-SIZE-OTHER-OBJ-NEXT: R_REF __llvm_prf_vnds