1 ## This test checks how llvm-readobj prints the PGO Analysis Map with the
2 ## --bb-addr-map option.
5 # RUN: yaml2obj %s -DBITS=64 -DADDR=0x999999999 -o %t1.x64.o
6 # RUN: llvm-readobj %t1.x64.o --bb-addr-map 2>&1 | FileCheck --match-full-lines %s -DADDR=0x999999999 -DFILE=%t1.x64.o --check-prefixes=CHECK,RAW
7 # RUN: llvm-readobj %t1.x64.o --bb-addr-map --pretty-pgo-analysis-map 2>&1 | FileCheck --match-full-lines %s -DADDR=0x999999999 -DFILE=%t1.x64.o --check-prefixes=CHECK,PRETTY
8 # RUN: llvm-readelf %t1.x64.o --bb-addr-map | FileCheck %s --check-prefix=GNU
9 # RUN: llvm-readobj %t1.x64.o --pretty-pgo-analysis-map 2>&1 | FileCheck %s --check-prefix=PRETTY-NO-BAM
12 # RUN: yaml2obj %s -DBITS=32 -o %t1.x32.o
13 # RUN: llvm-readobj %t1.x32.o --bb-addr-map 2>&1 | FileCheck --match-full-lines -DADDR=0x11111 %s -DFILE=%t1.x32.o --check-prefixes=CHECK,RAW
14 # RUN: llvm-readelf %t1.x32.o --bb-addr-map | FileCheck %s --check-prefix=GNU
16 ## Check that a malformed section can be handled.
17 # RUN: yaml2obj %s -DBITS=32 -DSIZE=24 -o %t2.o
18 # RUN: llvm-readobj %t2.o --bb-addr-map 2>&1 | FileCheck --match-full-lines %s -DOFFSET=0x00000018 -DFILE=%t2.o --check-prefix=TRUNCATED
20 ## Check that missing features can be handled.
21 # RUN: yaml2obj %s -DBITS=32 -DFEATURE=0x2 -o %t3.o
22 # RUN: llvm-readobj %t3.o --bb-addr-map 2>&1 | FileCheck %s -DFILE=%t3.o --check-prefix=INVALIDFT
25 # CHECK-NEXT: Function {
26 # CHECK-NEXT: At: [[ADDR]]
27 # CHECK-NEXT: {{.*}}: warning: '[[FILE]]': could not identify function symbol for address ([[ADDR]]) in SHT_LLVM_BB_ADDR_MAP section with index 3
28 # CHECK-NEXT: Name: <?>
29 # CHECK-NEXT: BB Ranges [
31 # CHECK-NEXT: Base Address: [[ADDR]]
32 # CHECK-NEXT: BB Entries [
35 # CHECK-NEXT: Offset: 0x0
36 # CHECK-NEXT: Size: 0x1
37 # CHECK-NEXT: HasReturn: No
38 # CHECK-NEXT: HasTailCall: Yes
39 # CHECK-NEXT: IsEHPad: No
40 # CHECK-NEXT: CanFallThrough: No
41 # CHECK-NEXT: HasIndirectBranch: No
45 # CHECK-NEXT: Offset: 0x4
46 # CHECK-NEXT: Size: 0x4
47 # CHECK-NEXT: HasReturn: Yes
48 # CHECK-NEXT: HasTailCall: No
49 # CHECK-NEXT: IsEHPad: Yes
50 # CHECK-NEXT: CanFallThrough: No
51 # CHECK-NEXT: HasIndirectBranch: Yes
56 # CHECK-NEXT: PGO analyses {
57 # CHECK-NEXT: FuncEntryCount: 100
58 # CHECK-NEXT: PGO BB entries [
60 # RAW-NEXT: Frequency: 100
61 # PRETTY-NEXT: Frequency: 1.0
62 # CHECK-NEXT: Successors [
65 # RAW-NEXT: Probability: 0x80000000
66 # PRETTY-NEXT: Probability: 0x80000000 / 0x80000000 = 100.00%
71 # RAW-NEXT: Frequency: 100
72 # PRETTY-NEXT: Frequency: 1.0
73 # CHECK-NEXT: Successors [
79 # CHECK-NEXT: Function {
80 # CHECK-NEXT: At: 0x22222
81 # CHECK-NEXT: Name: foo
82 # CHECK-NEXT: BB Ranges [
84 # CHECK-NEXT: Base Address: 0x22222
85 # CHECK-NEXT: BB Entries [
88 # CHECK-NEXT: Offset: 0x6
89 # CHECK-NEXT: Size: 0x7
90 # CHECK-NEXT: HasReturn: No
91 # CHECK-NEXT: HasTailCall: No
92 # CHECK-NEXT: IsEHPad: No
93 # CHECK-NEXT: CanFallThrough: Yes
94 # CHECK-NEXT: HasIndirectBranch: No
99 # CHECK-NEXT: PGO analyses {
100 # CHECK-NEXT: FuncEntryCount: 8888
101 # CHECK-NEXT: PGO BB entries [
103 # RAW-NEXT: Frequency: 9000
104 # PRETTY-NEXT: Frequency: 1.0
111 # GNU: GNUStyle::printBBAddrMaps not implemented
113 # PRETTY-NO-BAM: warning: --bb-addr-map must be enabled for --pretty-pgo-analysis-map to have an effect
115 # TRUNCATED: BBAddrMap [
116 # TRUNCATED-NEXT: {{.*}}: warning: '[[FILE]]': unable to dump SHT_LLVM_BB_ADDR_MAP section with index 3: unable to decode LEB128 at offset [[OFFSET]]: malformed uleb128, extends past end
118 ## Check that the other valid section is properly dumped.
119 # TRUNCATED-NEXT: BBAddrMap [
120 # TRUNCATED-NEXT: Function {
121 # TRUNCATED-NEXT: At: 0x33333
122 # TRUNCATED-NEXT: Name: bar
123 # TRUNCATED-NEXT: BB Ranges [
125 # TRUNCATED-NEXT: Base Address: 0x33333
126 # TRUNCATED-NEXT: BB Entries [
128 # TRUNCATED-NEXT: ID: 6
129 # TRUNCATED-NEXT: Offset: 0x9
130 # TRUNCATED-NEXT: Size: 0xA
131 # TRUNCATED-NEXT: HasReturn: Yes
132 # TRUNCATED-NEXT: HasTailCall: Yes
133 # TRUNCATED-NEXT: IsEHPad: No
134 # TRUNCATED-NEXT: CanFallThrough: Yes
135 # TRUNCATED-NEXT: HasIndirectBranch: Yes
138 # TRUNCATED-NEXT: ID: 7
139 # TRUNCATED-NEXT: Offset: 0x1F
140 # TRUNCATED-NEXT: Size: 0xD
141 # TRUNCATED-NEXT: HasReturn: No
142 # TRUNCATED-NEXT: HasTailCall: Yes
143 # TRUNCATED-NEXT: IsEHPad: Yes
144 # TRUNCATED-NEXT: CanFallThrough: Yes
145 # TRUNCATED-NEXT: HasIndirectBranch: No
150 # TRUNCATED-NEXT: PGO analyses {
151 # TRUNCATED-NEXT: FuncEntryCount: 89
156 # INVALIDFT: warning: '[[FILE]]': unable to dump SHT_LLVM_BB_ADDR_MAP section with index 5: unable to decode LEB128 at offset 0x00000010: malformed uleb128, extends past end
160 Class: ELFCLASS[[BITS]]
170 - Name: .llvm_bb_addr_map
171 Type: SHT_LLVM_BB_ADDR_MAP
172 ShSize: [[SIZE=<none>]]
178 - BaseAddress: [[ADDR=0x11111]]
191 - BaseAddress: 0x22222
198 - FuncEntryCount: 100
206 - FuncEntryCount: 8888
209 - Name: dummy_section
212 - Name: '.llvm_bb_addr_map (1)'
213 Type: SHT_LLVM_BB_ADDR_MAP
217 Feature: [[FEATURE=0x1]]
219 - BaseAddress: 0x33333