| 1 | ## Test that in the presence of SHT_LLVM_BB_ADDR_MAP sections which also |
| 2 | ## contain PGO data, --symbolize-operands is able to label the basic blocks |
| 3 | ## correctly. |
| 4 | |
| 5 | ## Check the case where we only have entry counts. |
| 6 | |
| 7 | # RUN: yaml2obj --docnum=1 %s -o %t1 |
| 8 | # RUN: llvm-objdump %t1 -d --symbolize-operands --no-show-raw-insn --no-leading-addr | \ |
| 9 | # RUN: FileCheck %s --check-prefix=ENTRYCOUNT |
| 10 | |
| 11 | --- !ELF |
| 12 | FileHeader: |
| 13 | Class: ELFCLASS64 |
| 14 | Data: ELFDATA2LSB |
| 15 | Type: ET_EXEC |
| 16 | Machine: EM_X86_64 |
| 17 | Sections: |
| 18 | - Name: .text.foo |
| 19 | Type: SHT_PROGBITS |
| 20 | Address: 0x0 |
| 21 | Flags: [SHF_ALLOC, SHF_EXECINSTR] |
| 22 | Content: '50' |
| 23 | - Name: .llvm_bb_addr_map.foo |
| 24 | Type: SHT_LLVM_BB_ADDR_MAP |
| 25 | Link: .text.foo |
| 26 | Entries: |
| 27 | - Version: 2 |
| 28 | Feature: 0x1 |
| 29 | BBRanges: |
| 30 | - BaseAddress: 0x0 |
| 31 | BBEntries: |
| 32 | - ID: 3 |
| 33 | AddressOffset: 0x0 |
| 34 | Size: 0x1 |
| 35 | Metadata: 0x1 |
| 36 | PGOAnalyses: |
| 37 | - FuncEntryCount: 1000 |
| 38 | Symbols: |
| 39 | - Name: foo |
| 40 | Section: .text.foo |
| 41 | Value: 0x0 |
| 42 | |
| 43 | # ENTRYCOUNT: <foo>: |
| 44 | # ENTRYCOUNT: <BB3> (Entry count: 1000): |
| 45 | |
| 46 | ## Check the case where we have entry points and block frequency information |
| 47 | |
| 48 | # RUN: yaml2obj %s --docnum=2 -o %t2 |
| 49 | # RUN: llvm-objdump %t2 -d --symbolize-operands --no-show-raw-insn --no-leading-addr | \ |
| 50 | # RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=ENTRYCOUNT-BLOCKFREQ |
| 51 | # RUN: llvm-objdump %t2 -d --symbolize-operands --pretty-pgo-analysis-map --no-show-raw-insn --no-leading-addr | \ |
| 52 | # RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=ENTRYCOUNT-BLOCKFREQ-PRETTY |
| 53 | |
| 54 | --- !ELF |
| 55 | FileHeader: |
| 56 | Class: ELFCLASS64 |
| 57 | Data: ELFDATA2LSB |
| 58 | Type: ET_EXEC |
| 59 | Machine: EM_X86_64 |
| 60 | Sections: |
| 61 | - Name: .text.foo |
| 62 | Type: SHT_PROGBITS |
| 63 | Address: 0x0 |
| 64 | Flags: [SHF_ALLOC, SHF_EXECINSTR] |
| 65 | Content: '503b0505200000907d02ebf5c3' |
| 66 | - Name: .llvm_bb_addr_map.foo |
| 67 | Type: SHT_LLVM_BB_ADDR_MAP |
| 68 | Link: .text.foo |
| 69 | Entries: |
| 70 | - Version: 2 |
| 71 | Feature: 0x3 |
| 72 | BBRanges: |
| 73 | - BaseAddress: 0x0 |
| 74 | BBEntries: |
| 75 | - ID: 3 |
| 76 | AddressOffset: 0x0 |
| 77 | Size: 0x1 |
| 78 | Metadata: 0x1 |
| 79 | - ID: 1 |
| 80 | AddressOffset: 0x0 |
| 81 | Size: 0x6 |
| 82 | Metadata: 0x0 |
| 83 | - ID: 2 |
| 84 | AddressOffset: 0x1 |
| 85 | Size: 0x4 |
| 86 | Metadata: 0x0 |
| 87 | - ID: 5 |
| 88 | AddressOffset: 0x0 |
| 89 | Size: 0x1 |
| 90 | Metadata: 0x2 |
| 91 | PGOAnalyses: |
| 92 | - FuncEntryCount: 1000 |
| 93 | PGOBBEntries: |
| 94 | - BBFreq: 1000 |
| 95 | - BBFreq: 133 |
| 96 | - BBFreq: 18 |
| 97 | - BBFreq: 1000 |
| 98 | Symbols: |
| 99 | - Name: foo |
| 100 | Section: .text.foo |
| 101 | Value: 0x0 |
| 102 | |
| 103 | # ENTRYCOUNT-BLOCKFREQ:<foo>: |
| 104 | # ENTRYCOUNT-BLOCKFREQ:<BB3> (Entry count: 1000, Frequency: 1000): |
| 105 | # ENTRYCOUNT-BLOCKFREQ:<BB1> (Frequency: 133): |
| 106 | # ENTRYCOUNT-BLOCKFREQ:<BB2> (Frequency: 18): |
| 107 | # ENTRYCOUNT-BLOCKFREQ:<BB5> (Frequency: 1000): |
| 108 | |
| 109 | # ENTRYCOUNT-BLOCKFREQ-PRETTY:<foo>: |
| 110 | # ENTRYCOUNT-BLOCKFREQ-PRETTY:<BB3> (Entry count: 1000, Frequency: 1.0): |
| 111 | # ENTRYCOUNT-BLOCKFREQ-PRETTY:<BB1> (Frequency: 0.133): |
| 112 | # ENTRYCOUNT-BLOCKFREQ-PRETTY:<BB2> (Frequency: 0.018): |
| 113 | # ENTRYCOUNT-BLOCKFREQ-PRETTY:<BB5> (Frequency: 1.0): |
| 114 | |
| 115 | ## Check the case where we have entry points, block frequency, and branch |
| 116 | ## proabability information. |
| 117 | |
| 118 | # RUN: yaml2obj %s --docnum=3 -o %t3 |
| 119 | # RUN: llvm-objdump %t3 -d --symbolize-operands --no-show-raw-insn --no-leading-addr | \ |
| 120 | # RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=ENTRY-FREQ-PROB |
| 121 | # RUN: llvm-objdump %t3 -d --symbolize-operands --pretty-pgo-analysis-map --no-show-raw-insn --no-leading-addr | \ |
| 122 | # RUN: FileCheck --match-full-lines --strict-whitespace %s --check-prefix=ENTRY-FREQ-PROB-PRETTY |
| 123 | # RUN: llvm-objdump %t3 -d --pretty-pgo-analysis-map --no-show-raw-insn --no-leading-addr 2>&1 | \ |
| 124 | # RUN: FileCheck %s --check-prefix=MISSING-SYMBOLIZE-OPERANDS |
| 125 | |
| 126 | --- !ELF |
| 127 | FileHeader: |
| 128 | Class: ELFCLASS64 |
| 129 | Data: ELFDATA2LSB |
| 130 | Type: ET_EXEC |
| 131 | Machine: EM_X86_64 |
| 132 | Sections: |
| 133 | - Name: .text.foo |
| 134 | Type: SHT_PROGBITS |
| 135 | Address: 0x0 |
| 136 | Flags: [SHF_ALLOC, SHF_EXECINSTR] |
| 137 | Content: '503b0505200000907d02ebf5c3' |
| 138 | - Name: .llvm_bb_addr_map.foo |
| 139 | Type: SHT_LLVM_BB_ADDR_MAP |
| 140 | Link: .text.foo |
| 141 | Entries: |
| 142 | - Version: 2 |
| 143 | Feature: 0x7 |
| 144 | BBRanges: |
| 145 | - BaseAddress: 0x0 |
| 146 | BBEntries: |
| 147 | - ID: 3 |
| 148 | AddressOffset: 0x0 |
| 149 | Size: 0x1 |
| 150 | Metadata: 0x1 |
| 151 | - ID: 1 |
| 152 | AddressOffset: 0x0 |
| 153 | Size: 0x6 |
| 154 | Metadata: 0x0 |
| 155 | - ID: 2 |
| 156 | AddressOffset: 0x1 |
| 157 | Size: 0x4 |
| 158 | Metadata: 0x0 |
| 159 | - ID: 5 |
| 160 | AddressOffset: 0x0 |
| 161 | Size: 0x1 |
| 162 | Metadata: 0x2 |
| 163 | PGOAnalyses: |
| 164 | - FuncEntryCount: 1000 |
| 165 | PGOBBEntries: |
| 166 | - BBFreq: 1000 |
| 167 | Successors: |
| 168 | - ID: 1 |
| 169 | BrProb: 0x10000000 |
| 170 | - ID: 2 |
| 171 | BrProb: 0x15000000 |
| 172 | - ID: 3 |
| 173 | BrProb: 0x50000000 |
| 174 | - BBFreq: 133 |
| 175 | Successors: |
| 176 | - ID: 2 |
| 177 | BrProb: 0x10000000 |
| 178 | - ID: 3 |
| 179 | BrProb: 0x70000000 |
| 180 | - BBFreq: 18 |
| 181 | Successors: |
| 182 | - ID: 3 |
| 183 | BrProb: 0x80000000 |
| 184 | - BBFreq: 1000 |
| 185 | Successors: [] |
| 186 | Symbols: |
| 187 | - Name: foo |
| 188 | Section: .text.foo |
| 189 | Value: 0x0 |
| 190 | |
| 191 | # ENTRY-FREQ-PROB:<foo>: |
| 192 | # ENTRY-FREQ-PROB:<BB3> (Entry count: 1000, Frequency: 1000, Successors: BB1:10000000, BB2:15000000, BB3:50000000): |
| 193 | # ENTRY-FREQ-PROB:<BB1> (Frequency: 133, Successors: BB2:10000000, BB3:70000000): |
| 194 | # ENTRY-FREQ-PROB:<BB2> (Frequency: 18, Successors: BB3:80000000): |
| 195 | # ENTRY-FREQ-PROB:<BB5> (Frequency: 1000): |
| 196 | |
| 197 | # ENTRY-FREQ-PROB-PRETTY:<foo>: |
| 198 | # ENTRY-FREQ-PROB-PRETTY:<BB3> (Entry count: 1000, Frequency: 1.0, Successors: BB1:[0x10000000 / 0x80000000 = 12.50%], BB2:[0x15000000 / 0x80000000 = 16.41%], BB3:[0x50000000 / 0x80000000 = 62.50%]): |
| 199 | # ENTRY-FREQ-PROB-PRETTY:<BB1> (Frequency: 0.133, Successors: BB2:[0x10000000 / 0x80000000 = 12.50%], BB3:[0x70000000 / 0x80000000 = 87.50%]): |
| 200 | # ENTRY-FREQ-PROB-PRETTY:<BB2> (Frequency: 0.018, Successors: BB3:[0x80000000 / 0x80000000 = 100.00%]): |
| 201 | # ENTRY-FREQ-PROB-PRETTY:<BB5> (Frequency: 1.0): |
| 202 | |
| 203 | # MISSING-SYMBOLIZE-OPERANDS: warning: --symbolize-operands must be enabled for --pretty-pgo-analysis-map to have an effect |