[clang] Propagate -ftime-report to offload lto (#122143)
[llvm-project.git] / llvm / test / tools / llvm-readobj / ELF / bb-addr-map-pgo-analysis-map.test
blob5faafd4d83b2f201f999b7948fd4d0bf19a3fc70
1 ## This test checks how llvm-readobj prints the PGO Analysis Map with the
2 ## --bb-addr-map option.
4 ## Check 64-bit:
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
11 ## Check 32-bit:
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
24 # CHECK:      BBAddrMap [
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 [
30 # CHECK-NEXT:       {
31 # CHECK-NEXT:         Base Address: [[ADDR]]
32 # CHECK-NEXT:         BB Entries [
33 # CHECK-NEXT:           {
34 # CHECK-NEXT:             ID: 0
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
42 # CHECK-NEXT:           }
43 # CHECK-NEXT:           {
44 # CHECK-NEXT:             ID: 2
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
52 # CHECK-NEXT:           }
53 # CHECK-NEXT:         ]
54 # CHECK-NEXT:       }
55 # CHECK-NEXT:     ]
56 # CHECK-NEXT:     PGO analyses {
57 # CHECK-NEXT:       FuncEntryCount: 100
58 # CHECK-NEXT:       PGO BB entries [
59 # CHECK-NEXT:         {
60 # RAW-NEXT:             Frequency: 100
61 # PRETTY-NEXT:          Frequency: 1.0
62 # CHECK-NEXT:           Successors [
63 # CHECK-NEXT:             {
64 # CHECK-NEXT:               ID: 2
65 # RAW-NEXT:                 Probability: 0x80000000
66 # PRETTY-NEXT:              Probability: 0x80000000 / 0x80000000 = 100.00%
67 # CHECK-NEXT:             }
68 # CHECK-NEXT:           ]
69 # CHECK-NEXT:         }
70 # CHECK-NEXT:         {
71 # RAW-NEXT:             Frequency: 100
72 # PRETTY-NEXT:          Frequency: 1.0
73 # CHECK-NEXT:           Successors [
74 # CHECK-NEXT:           ]
75 # CHECK-NEXT:         }
76 # CHECK-NEXT:       ]
77 # CHECK-NEXT:     }
78 # CHECK-NEXT:   }
79 # CHECK-NEXT:   Function {
80 # CHECK-NEXT:     At: 0x22222
81 # CHECK-NEXT:     Name: foo
82 # CHECK-NEXT:     BB Ranges [
83 # CHECK-NEXT:       {
84 # CHECK-NEXT:         Base Address: 0x22222
85 # CHECK-NEXT:         BB Entries [
86 # CHECK-NEXT:           {
87 # CHECK-NEXT:             ID: 4
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
95 # CHECK-NEXT:           }
96 # CHECK-NEXT:         ]
97 # CHECK-NEXT:       }
98 # CHECK-NEXT:     ]
99 # CHECK-NEXT:     PGO analyses {
100 # CHECK-NEXT:       FuncEntryCount: 8888
101 # CHECK-NEXT:       PGO BB entries [
102 # CHECK-NEXT:         {
103 # RAW-NEXT:             Frequency: 9000
104 # PRETTY-NEXT:          Frequency: 1.0
105 # CHECK-NEXT:         }
106 # CHECK-NEXT:       ]
107 # CHECK-NEXT:     }
108 # CHECK-NEXT:   }
109 # CHECK-NEXT: ]
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
117 # TRUNCATED-NEXT: ]
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 [
124 # TRUNCATED-NEXT:       {
125 # TRUNCATED-NEXT:         Base Address: 0x33333
126 # TRUNCATED-NEXT:         BB Entries [
127 # TRUNCATED-NEXT:           {
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
136 # TRUNCATED-NEXT:           }
137 # TRUNCATED-NEXT:           {
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
146 # TRUNCATED-NEXT:           }
147 # TRUNCATED-NEXT:         ]
148 # TRUNCATED-NEXT:       }
149 # TRUNCATED-NEXT:     ]
150 # TRUNCATED-NEXT:     PGO analyses {
151 # TRUNCATED-NEXT:       FuncEntryCount: 89
152 # TRUNCATED-NEXT:     }
153 # TRUNCATED-NEXT:   }
154 # TRUNCATED-NEXT: ]
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
158 --- !ELF
159 FileHeader:
160   Class: ELFCLASS[[BITS]]
161   Data:  ELFDATA2LSB
162   Type:  ET_EXEC
163 Sections:
164   - Name:   .text
165     Type:   SHT_PROGBITS
166     Flags:  [SHF_ALLOC]
167   - Name:   .text.bar
168     Type:   SHT_PROGBITS
169     Flags:  [SHF_ALLOC]
170   - Name:   .llvm_bb_addr_map
171     Type:   SHT_LLVM_BB_ADDR_MAP
172     ShSize: [[SIZE=<none>]]
173     Link:   .text
174     Entries:
175       - Version: 2
176         Feature: 0x7
177         BBRanges:
178           - BaseAddress: [[ADDR=0x11111]]
179             BBEntries:
180               - ID:            0
181                 AddressOffset: 0x0
182                 Size:          0x1
183                 Metadata:      0x2
184               - ID:            2
185                 AddressOffset: 0x3
186                 Size:          0x4
187                 Metadata:      0x15
188       - Version: 2
189         Feature: 0x3
190         BBRanges:
191           - BaseAddress: 0x22222
192             BBEntries:
193               - ID:            4
194                 AddressOffset: 0x6
195                 Size:          0x7
196                 Metadata:      0x8
197     PGOAnalyses:
198       - FuncEntryCount: 100
199         PGOBBEntries:
200           - BBFreq:        100
201             Successors:
202               - ID:        2
203                 BrProb:    0x80000000
204           - BBFreq:        100
205             Successors:    []
206       - FuncEntryCount: 8888
207         PGOBBEntries:
208           - BBFreq:        9000
209   - Name: dummy_section
210     Type: SHT_PROGBITS
211     Size: 16
212   - Name: '.llvm_bb_addr_map (1)'
213     Type: SHT_LLVM_BB_ADDR_MAP
214     Link: .text.bar
215     Entries:
216       - Version: 2
217         Feature: [[FEATURE=0x1]]
218         BBRanges:
219           - BaseAddress: 0x33333
220             BBEntries:
221               - ID:            6
222                 AddressOffset: 0x9
223                 Size:          0xa
224                 Metadata:      0x1b
225               - ID:            7
226                 AddressOffset: 0xc
227                 Size:          0xd
228                 Metadata:      0xe
229     PGOAnalyses:
230       - FuncEntryCount: 89
231 Symbols:
232   - Name:    foo
233     Section: .text
234     Type:    STT_FUNC
235     Value:   0x22222
236   - Name:    bar
237     Section: .text.bar
238     Type:    STT_FUNC
239     Value:   0x33333