1; RUN: rm -rf %t && split-file %s %t
2
3; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff -xcoff-traceback-table=false < %t/no-ref.ll | FileCheck %s --check-prefixes=NOREF
4; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff -xcoff-traceback-table=false < %t/no-vnds.ll | FileCheck %s --check-prefixes=NOVNDS
5; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff -xcoff-traceback-table=false < %t/with-vnds.ll | FileCheck %s --check-prefixes=WITHVNDS
6
7
8;--- no-ref.ll
9; The absence of a __llvm_prf_cnts section should stop generating the .refs.
10;
11target datalayout = "E-m:a-p:32:32-i64:64-n32"
12target triple = "powerpc-ibm-aix7.2.0.0"
13
14@__profd_main = private global i64 zeroinitializer, section "__llvm_prf_data", align 8
15@__llvm_prf_nm = private constant [6 x i8] c"\04\00main", section "__llvm_prf_names", align 1
16
17@llvm.used = appending global [2 x i8*]
18  [i8* bitcast (i64* @__profd_main to i8*),
19   i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__llvm_prf_nm, i32 0, i32 0)], section "llvm.metadata"
20
21define i32 @main() #0 {
22entry:
23  ret i32 1
24}
25
26; NOREF-NOT:  .ref __llvm_prf_data
27; NOREF-NOT:  .ref __llvm_prf_names
28; NOREF-NOT:  .ref __llvm_prf_vnds
29
30;--- no-vnds.ll
31; 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.
32;
33target datalayout = "E-m:a-p:32:32-i64:64-n32"
34target triple = "powerpc-ibm-aix7.2.0.0"
35
36@__profc_main = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
37@__profd_main = private global i64 zeroinitializer, section "__llvm_prf_data", align 8
38@__llvm_prf_nm = private constant [6 x i8] c"\04\00main", section "__llvm_prf_names", align 1
39
40@llvm.used = appending global [3 x i8*]
41  [i8* bitcast ([1 x i64]* @__profc_main to i8*),
42   i8* bitcast (i64* @__profd_main to i8*),
43   i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__llvm_prf_nm, i32 0, i32 0)], section "llvm.metadata"
44
45define i32 @main() #0 {
46entry:
47  ret i32 1
48}
49; There will be two __llvm_prf_cnts .csects, one to represent the actual csect
50; that holds @__profc_main, and one generated to hold the .ref directives. In
51; XCOFF, a csect can be defined in pieces, so this is is legal assembly.
52;
53; NOVNDS:      .csect __llvm_prf_cnts[RW],3
54; NOVNDS:      .csect __llvm_prf_cnts[RW],3
55; NOVNDS-NEXT: .ref __llvm_prf_data[RW]
56; NOVNDS-NEXT: .ref __llvm_prf_names[RO]
57; NOVNDS-NOT:  .ref __llvm_prf_vnds
58
59;--- with-vnds.ll
60; When value profiling is needed, the PGO instrumentation generates variables in the __llvm_prf_vnds section, so we generate a .ref for them too.
61;
62@__profc_main = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
63@__profd_main = private global i64 zeroinitializer, section "__llvm_prf_data", align 8
64@__llvm_prf_nm = private constant [6 x i8] c"\04\00main", section "__llvm_prf_names", align 1
65@__llvm_prf_vnodes = private global [10 x { i64, i64, i8* }] zeroinitializer, section "__llvm_prf_vnds"
66
67@llvm.used = appending global [4 x i8*]
68  [i8* bitcast ([1 x i64]* @__profc_main to i8*),
69   i8* bitcast (i64* @__profd_main to i8*),
70   i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__llvm_prf_nm, i32 0, i32 0),
71   i8* bitcast ([10 x { i64, i64, i8* }]* @__llvm_prf_vnodes to i8*)], section "llvm.metadata"
72
73define i32 @main() #0 {
74entry:
75  ret i32 1
76}
77
78; WITHVNDS:      .csect __llvm_prf_cnts[RW],3
79; WITHVNDS:      .csect __llvm_prf_cnts[RW],3
80; WITHVNDS-NEXT: .ref __llvm_prf_data[RW]
81; WITHVNDS-NEXT: .ref __llvm_prf_names[RO]
82; WITHVNDS-NEXT: .ref __llvm_prf_vnds[RW]
83