1# REQUIRES: system-linux 2 3# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o 4# RUN: %clang %cflags -dwarf-4 %tmain.o -o %t.exe -Wl,-q 5# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --use-old-text 6# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt > %t.txt 7# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe >> %t.txt 8# RUN: cat %t.txt | FileCheck --check-prefix=CHECK %s 9 10# CHECK: DW_TAG_inlined_subroutine 11# CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,ADDR:]]) 12# CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000000) 13 14# CHECK: DW_TAG_inlined_subroutine 15# CHECK-NOT: DW_AT_low_pc [DW_FORM_addr] (0x[[#ADDR]]) 16# CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000000) 17 18 19## Testing BOLT handles correctly when size of DW_AT_inlined_subroutine is 0. 20## In other words DW_AT_high_pc is 0 or DW_AT_low_pc == DW_AT_high_pc. 21 22# Modified assembly manually to set DW_AT_high_pc to 0. 23# clang++ -g2 -gdwarf-4 main.cpp -O1 -S -o main4.s 24 25# static int helper(int i) { 26# return ++i; 27# } 28# void may_not_exist(void) __attribute__ ((weak)); 29# int main(int argc, char *argv[]) { 30# if (may_not_exist) 31# may_not_exist(); 32# int j = 0; 33# [[clang::always_inline]] j = helper(argc); 34# return j; 35# } 36 37 38 .text 39 .file "main.cpp" 40 .globl main # -- Begin function main 41 .p2align 4, 0x90 42 .type main,@function 43main: # @main 44.Lfunc_begin0: 45 .file 1 "." "main.cpp" 46 .loc 1 5 0 # main.cpp:5:0 47 .cfi_startproc 48# %bb.0: # %entry 49 #DEBUG_VALUE: main:argc <- $edi 50 #DEBUG_VALUE: main:argv <- $rsi 51 pushq %rbx 52 .cfi_def_cfa_offset 16 53 .cfi_offset %rbx, -16 54 movl %edi, %ebx 55.Ltmp0: 56 .loc 1 6 7 prologue_end # main.cpp:6:7 57 cmpq $0, _Z13may_not_existv@GOTPCREL(%rip) 58 je .LBB0_2 59.Ltmp1: 60# %bb.1: # %if.then 61 #DEBUG_VALUE: main:argc <- $ebx 62 #DEBUG_VALUE: main:argv <- $rsi 63 .loc 1 7 5 # main.cpp:7:5 64 callq _Z13may_not_existv@PLT 65.Ltmp2: 66 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi 67.LBB0_2: # %if.end 68 #DEBUG_VALUE: main:argc <- $ebx 69 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi 70 #DEBUG_VALUE: main:j <- 0 71 #DEBUG_VALUE: helper:i <- $ebx 72 .loc 1 2 10 # main.cpp:2:10 73 incl %ebx 74.Ltmp3: 75 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi 76 #DEBUG_VALUE: helper:i <- $ebx 77 #DEBUG_VALUE: main:j <- $ebx 78 .loc 1 10 3 # main.cpp:10:3 79 movl %ebx, %eax 80 popq %rbx 81.Ltmp4: 82 #DEBUG_VALUE: helper:i <- $eax 83 #DEBUG_VALUE: main:j <- $eax 84 .cfi_def_cfa_offset 8 85 retq 86.Ltmp5: 87.Lfunc_end0: 88 .size main, .Lfunc_end0-main 89 .cfi_endproc 90 # -- End function 91 .section .debug_loc,"",@progbits 92.Ldebug_loc0: 93 .quad .Lfunc_begin0-.Lfunc_begin0 94 .quad .Ltmp1-.Lfunc_begin0 95 .short 1 # Loc expr size 96 .byte 85 # super-register DW_OP_reg5 97 .quad .Ltmp1-.Lfunc_begin0 98 .quad .Ltmp3-.Lfunc_begin0 99 .short 1 # Loc expr size 100 .byte 83 # super-register DW_OP_reg3 101 .quad .Ltmp3-.Lfunc_begin0 102 .quad .Lfunc_end0-.Lfunc_begin0 103 .short 4 # Loc expr size 104 .byte 243 # DW_OP_GNU_entry_value 105 .byte 1 # 1 106 .byte 85 # super-register DW_OP_reg5 107 .byte 159 # DW_OP_stack_value 108 .quad 0 109 .quad 0 110.Ldebug_loc1: 111 .quad .Lfunc_begin0-.Lfunc_begin0 112 .quad .Ltmp2-.Lfunc_begin0 113 .short 1 # Loc expr size 114 .byte 84 # DW_OP_reg4 115 .quad .Ltmp2-.Lfunc_begin0 116 .quad .Lfunc_end0-.Lfunc_begin0 117 .short 4 # Loc expr size 118 .byte 243 # DW_OP_GNU_entry_value 119 .byte 1 # 1 120 .byte 84 # DW_OP_reg4 121 .byte 159 # DW_OP_stack_value 122 .quad 0 123 .quad 0 124.Ldebug_loc2: 125 .quad .Ltmp2-.Lfunc_begin0 126 .quad .Ltmp3-.Lfunc_begin0 127 .short 3 # Loc expr size 128 .byte 17 # DW_OP_consts 129 .byte 0 # 0 130 .byte 159 # DW_OP_stack_value 131 .quad .Ltmp3-.Lfunc_begin0 132 .quad .Ltmp4-.Lfunc_begin0 133 .short 1 # Loc expr size 134 .byte 83 # super-register DW_OP_reg3 135 .quad .Ltmp4-.Lfunc_begin0 136 .quad .Lfunc_end0-.Lfunc_begin0 137 .short 1 # Loc expr size 138 .byte 80 # super-register DW_OP_reg0 139 .quad 0 140 .quad 0 141 .section .debug_abbrev,"",@progbits 142 .byte 1 # Abbreviation Code 143 .byte 17 # DW_TAG_compile_unit 144 .byte 1 # DW_CHILDREN_yes 145 .byte 37 # DW_AT_producer 146 .byte 14 # DW_FORM_strp 147 .byte 19 # DW_AT_language 148 .byte 5 # DW_FORM_data2 149 .byte 3 # DW_AT_name 150 .byte 14 # DW_FORM_strp 151 .byte 16 # DW_AT_stmt_list 152 .byte 23 # DW_FORM_sec_offset 153 .byte 27 # DW_AT_comp_dir 154 .byte 14 # DW_FORM_strp 155 .byte 17 # DW_AT_low_pc 156 .byte 1 # DW_FORM_addr 157 .byte 18 # DW_AT_high_pc 158 .byte 6 # DW_FORM_data4 159 .byte 0 # EOM(1) 160 .byte 0 # EOM(2) 161 .byte 2 # Abbreviation Code 162 .byte 46 # DW_TAG_subprogram 163 .byte 1 # DW_CHILDREN_yes 164 .byte 110 # DW_AT_linkage_name 165 .byte 14 # DW_FORM_strp 166 .byte 3 # DW_AT_name 167 .byte 14 # DW_FORM_strp 168 .byte 58 # DW_AT_decl_file 169 .byte 11 # DW_FORM_data1 170 .byte 59 # DW_AT_decl_line 171 .byte 11 # DW_FORM_data1 172 .byte 73 # DW_AT_type 173 .byte 19 # DW_FORM_ref4 174 .byte 32 # DW_AT_inline 175 .byte 11 # DW_FORM_data1 176 .byte 0 # EOM(1) 177 .byte 0 # EOM(2) 178 .byte 3 # Abbreviation Code 179 .byte 5 # DW_TAG_formal_parameter 180 .byte 0 # DW_CHILDREN_no 181 .byte 3 # DW_AT_name 182 .byte 14 # DW_FORM_strp 183 .byte 58 # DW_AT_decl_file 184 .byte 11 # DW_FORM_data1 185 .byte 59 # DW_AT_decl_line 186 .byte 11 # DW_FORM_data1 187 .byte 73 # DW_AT_type 188 .byte 19 # DW_FORM_ref4 189 .byte 0 # EOM(1) 190 .byte 0 # EOM(2) 191 .byte 4 # Abbreviation Code 192 .byte 36 # DW_TAG_base_type 193 .byte 0 # DW_CHILDREN_no 194 .byte 3 # DW_AT_name 195 .byte 14 # DW_FORM_strp 196 .byte 62 # DW_AT_encoding 197 .byte 11 # DW_FORM_data1 198 .byte 11 # DW_AT_byte_size 199 .byte 11 # DW_FORM_data1 200 .byte 0 # EOM(1) 201 .byte 0 # EOM(2) 202 .byte 5 # Abbreviation Code 203 .byte 46 # DW_TAG_subprogram 204 .byte 1 # DW_CHILDREN_yes 205 .byte 17 # DW_AT_low_pc 206 .byte 1 # DW_FORM_addr 207 .byte 18 # DW_AT_high_pc 208 .byte 6 # DW_FORM_data4 209 .byte 64 # DW_AT_frame_base 210 .byte 24 # DW_FORM_exprloc 211 .ascii "\227B" # DW_AT_GNU_all_call_sites 212 .byte 25 # DW_FORM_flag_present 213 .byte 3 # DW_AT_name 214 .byte 14 # DW_FORM_strp 215 .byte 58 # DW_AT_decl_file 216 .byte 11 # DW_FORM_data1 217 .byte 59 # DW_AT_decl_line 218 .byte 11 # DW_FORM_data1 219 .byte 73 # DW_AT_type 220 .byte 19 # DW_FORM_ref4 221 .byte 63 # DW_AT_external 222 .byte 25 # DW_FORM_flag_present 223 .byte 0 # EOM(1) 224 .byte 0 # EOM(2) 225 .byte 6 # Abbreviation Code 226 .byte 5 # DW_TAG_formal_parameter 227 .byte 0 # DW_CHILDREN_no 228 .byte 2 # DW_AT_location 229 .byte 23 # DW_FORM_sec_offset 230 .byte 3 # DW_AT_name 231 .byte 14 # DW_FORM_strp 232 .byte 58 # DW_AT_decl_file 233 .byte 11 # DW_FORM_data1 234 .byte 59 # DW_AT_decl_line 235 .byte 11 # DW_FORM_data1 236 .byte 73 # DW_AT_type 237 .byte 19 # DW_FORM_ref4 238 .byte 0 # EOM(1) 239 .byte 0 # EOM(2) 240 .byte 7 # Abbreviation Code 241 .byte 52 # DW_TAG_variable 242 .byte 0 # DW_CHILDREN_no 243 .byte 2 # DW_AT_location 244 .byte 23 # DW_FORM_sec_offset 245 .byte 3 # DW_AT_name 246 .byte 14 # DW_FORM_strp 247 .byte 58 # DW_AT_decl_file 248 .byte 11 # DW_FORM_data1 249 .byte 59 # DW_AT_decl_line 250 .byte 11 # DW_FORM_data1 251 .byte 73 # DW_AT_type 252 .byte 19 # DW_FORM_ref4 253 .byte 0 # EOM(1) 254 .byte 0 # EOM(2) 255 .byte 8 # Abbreviation Code 256 .byte 29 # DW_TAG_inlined_subroutine 257 .byte 1 # DW_CHILDREN_yes 258 .byte 49 # DW_AT_abstract_origin 259 .byte 19 # DW_FORM_ref4 260 .byte 17 # DW_AT_low_pc 261 .byte 1 # DW_FORM_addr 262 .byte 18 # DW_AT_high_pc 263 .byte 6 # DW_FORM_data4 264 .byte 88 # DW_AT_call_file 265 .byte 11 # DW_FORM_data1 266 .byte 89 # DW_AT_call_line 267 .byte 11 # DW_FORM_data1 268 .byte 87 # DW_AT_call_column 269 .byte 11 # DW_FORM_data1 270 .byte 0 # EOM(1) 271 .byte 0 # EOM(2) 272 .byte 9 # Abbreviation Code 273 .byte 5 # DW_TAG_formal_parameter 274 .byte 0 # DW_CHILDREN_no 275 .byte 2 # DW_AT_location 276 .byte 24 # DW_FORM_exprloc 277 .byte 49 # DW_AT_abstract_origin 278 .byte 19 # DW_FORM_ref4 279 .byte 0 # EOM(1) 280 .byte 0 # EOM(2) 281 .byte 10 # Abbreviation Code 282 .ascii "\211\202\001" # DW_TAG_GNU_call_site 283 .byte 0 # DW_CHILDREN_no 284 .byte 49 # DW_AT_abstract_origin 285 .byte 19 # DW_FORM_ref4 286 .byte 17 # DW_AT_low_pc 287 .byte 1 # DW_FORM_addr 288 .byte 0 # EOM(1) 289 .byte 0 # EOM(2) 290 .byte 11 # Abbreviation Code 291 .byte 46 # DW_TAG_subprogram 292 .byte 0 # DW_CHILDREN_no 293 .byte 110 # DW_AT_linkage_name 294 .byte 14 # DW_FORM_strp 295 .byte 3 # DW_AT_name 296 .byte 14 # DW_FORM_strp 297 .byte 58 # DW_AT_decl_file 298 .byte 11 # DW_FORM_data1 299 .byte 59 # DW_AT_decl_line 300 .byte 11 # DW_FORM_data1 301 .byte 60 # DW_AT_declaration 302 .byte 25 # DW_FORM_flag_present 303 .byte 63 # DW_AT_external 304 .byte 25 # DW_FORM_flag_present 305 .byte 0 # EOM(1) 306 .byte 0 # EOM(2) 307 .byte 12 # Abbreviation Code 308 .byte 15 # DW_TAG_pointer_type 309 .byte 0 # DW_CHILDREN_no 310 .byte 73 # DW_AT_type 311 .byte 19 # DW_FORM_ref4 312 .byte 0 # EOM(1) 313 .byte 0 # EOM(2) 314 .byte 0 # EOM(3) 315 .section .debug_info,"",@progbits 316.Lcu_begin0: 317 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 318.Ldebug_info_start0: 319 .short 4 # DWARF version number 320 .long .debug_abbrev # Offset Into Abbrev. Section 321 .byte 8 # Address Size (in bytes) 322 .byte 1 # Abbrev [1] 0xb:0xcf DW_TAG_compile_unit 323 .long .Linfo_string0 # DW_AT_producer 324 .short 33 # DW_AT_language 325 .long .Linfo_string1 # DW_AT_name 326 .long .Lline_table_start0 # DW_AT_stmt_list 327 .long .Linfo_string2 # DW_AT_comp_dir 328 .quad .Lfunc_begin0 # DW_AT_low_pc 329 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 330 .byte 2 # Abbrev [2] 0x2a:0x1c DW_TAG_subprogram 331 .long .Linfo_string3 # DW_AT_linkage_name 332 .long .Linfo_string4 # DW_AT_name 333 .byte 1 # DW_AT_decl_file 334 .byte 1 # DW_AT_decl_line 335 .long 70 # DW_AT_type 336 .byte 1 # DW_AT_inline 337 .byte 3 # Abbrev [3] 0x3a:0xb DW_TAG_formal_parameter 338 .long .Linfo_string6 # DW_AT_name 339 .byte 1 # DW_AT_decl_file 340 .byte 1 # DW_AT_decl_line 341 .long 70 # DW_AT_type 342 .byte 0 # End Of Children Mark 343 .byte 4 # Abbrev [4] 0x46:0x7 DW_TAG_base_type 344 .long .Linfo_string5 # DW_AT_name 345 .byte 5 # DW_AT_encoding 346 .byte 4 # DW_AT_byte_size 347 .byte 5 # Abbrev [5] 0x4d:0x70 DW_TAG_subprogram 348 .quad .Lfunc_begin0 # DW_AT_low_pc 349 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 350 .byte 1 # DW_AT_frame_base 351 .byte 87 352 # DW_AT_GNU_all_call_sites 353 .long .Linfo_string9 # DW_AT_name 354 .byte 1 # DW_AT_decl_file 355 .byte 5 # DW_AT_decl_line 356 .long 70 # DW_AT_type 357 # DW_AT_external 358 .byte 6 # Abbrev [6] 0x66:0xf DW_TAG_formal_parameter 359 .long .Ldebug_loc0 # DW_AT_location 360 .long .Linfo_string10 # DW_AT_name 361 .byte 1 # DW_AT_decl_file 362 .byte 5 # DW_AT_decl_line 363 .long 70 # DW_AT_type 364 .byte 6 # Abbrev [6] 0x75:0xf DW_TAG_formal_parameter 365 .long .Ldebug_loc1 # DW_AT_location 366 .long .Linfo_string11 # DW_AT_name 367 .byte 1 # DW_AT_decl_file 368 .byte 5 # DW_AT_decl_line 369 .long 200 # DW_AT_type 370 .byte 7 # Abbrev [7] 0x84:0xf DW_TAG_variable 371 .long .Ldebug_loc2 # DW_AT_location 372 .long .Linfo_string13 # DW_AT_name 373 .byte 1 # DW_AT_decl_file 374 .byte 8 # DW_AT_decl_line 375 .long 70 # DW_AT_type 376 .byte 8 # Abbrev [8] 0x93:0x1c DW_TAG_inlined_subroutine 377 .long 42 # DW_AT_abstract_origin 378 .quad .Ltmp2 # DW_AT_low_pc 379 .long 0 # DW_AT_high_pc Manually modified 380 .byte 1 # DW_AT_call_file 381 .byte 9 # DW_AT_call_line 382 .byte 32 # DW_AT_call_column 383 .byte 9 # Abbrev [9] 0xa7:0x7 DW_TAG_formal_parameter 384 .byte 1 # DW_AT_location 385 .byte 83 386 .long 58 # DW_AT_abstract_origin 387 .byte 0 # End Of Children Mark 388 .byte 10 # Abbrev [10] 0xaf:0xd DW_TAG_GNU_call_site 389 .long 189 # DW_AT_abstract_origin 390 .quad .Ltmp2 # DW_AT_low_pc 391 .byte 0 # End Of Children Mark 392 .byte 11 # Abbrev [11] 0xbd:0xb DW_TAG_subprogram 393 .long .Linfo_string7 # DW_AT_linkage_name 394 .long .Linfo_string8 # DW_AT_name 395 .byte 1 # DW_AT_decl_file 396 .byte 4 # DW_AT_decl_line 397 # DW_AT_declaration 398 # DW_AT_external 399 .byte 12 # Abbrev [12] 0xc8:0x5 DW_TAG_pointer_type 400 .long 205 # DW_AT_type 401 .byte 12 # Abbrev [12] 0xcd:0x5 DW_TAG_pointer_type 402 .long 210 # DW_AT_type 403 .byte 4 # Abbrev [4] 0xd2:0x7 DW_TAG_base_type 404 .long .Linfo_string12 # DW_AT_name 405 .byte 6 # DW_AT_encoding 406 .byte 1 # DW_AT_byte_size 407 .byte 0 # End Of Children Mark 408.Ldebug_info_end0: 409 .section .debug_str,"MS",@progbits,1 410.Linfo_string0: 411 .asciz "clang version 16.0.0" # string offset=0 412.Linfo_string1: 413 .asciz "main.cpp" # string offset=105 414.Linfo_string2: 415 .asciz "." # string offset=114 416.Linfo_string3: 417 .asciz "_ZL6helperi" # string offset=152 418.Linfo_string4: 419 .asciz "helper" # string offset=164 420.Linfo_string5: 421 .asciz "int" # string offset=171 422.Linfo_string6: 423 .asciz "i" # string offset=175 424.Linfo_string7: 425 .asciz "_Z13may_not_existv" # string offset=177 426.Linfo_string8: 427 .asciz "may_not_exist" # string offset=196 428.Linfo_string9: 429 .asciz "main" # string offset=210 430.Linfo_string10: 431 .asciz "argc" # string offset=215 432.Linfo_string11: 433 .asciz "argv" # string offset=220 434.Linfo_string12: 435 .asciz "char" # string offset=225 436.Linfo_string13: 437 .asciz "j" # string offset=230 438 .weak _Z13may_not_existv 439 .ident "clang version 16.0.0" 440 .section ".note.GNU-stack","",@progbits 441 .addrsig 442 .addrsig_sym _Z13may_not_existv 443 .section .debug_line,"",@progbits 444.Lline_table_start0: 445