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 -no-pie %s -o %t.exe -Wl,-q 5# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections 6# RUN: llvm-dwarfdump --show-children --name=main --debug-info %t.bolt \ 7# RUN: | FileCheck %s 8 9# CHECK: DW_TAG_inlined_subroutine 10# CHECK: DW_AT_low_pc 11# CHECK-SAME: 0x0000000000000000 12 13# CHECK: DW_TAG_GNU_call_site 14# CHECK: DW_AT_low_pc 15# CHECK-SAME: 0x0000000000000000 16 17## Test that llvm-bolt correctly updates DIEs corresponding to deleted code. 18 19# Test case built from the following source using: 20# 21# clang -O2 -g ... 22# 23# Assembly modified with "je" -> "jmp" to introduce unreachable block. 24# 25# extern void puts(const char *); 26# 27# static void foo() { 28# puts("hi"); 29# } 30# 31# int main(int argc, char **argv) { 32# if (argc) 33# foo(); 34# return 0; 35# } 36 37 .text 38 .file "unreachable.c" 39 .file 1 "." "unreachable.c" 40 .globl main # -- Begin function main 41 .p2align 4, 0x90 42 .type main,@function 43main: # @main 44.Lfunc_begin0: 45 .loc 1 7 0 # unreachable.c:7:0 46 .cfi_startproc 47# %bb.0: 48 #DEBUG_VALUE: main:argc <- $edi 49 #DEBUG_VALUE: main:argv <- $rsi 50 .loc 1 8 7 prologue_end # unreachable.c:8:7 51 testl %edi, %edi 52.Ltmp0: 53 .loc 1 8 7 is_stmt 0 # unreachable.c:8:7 54 jmp .LBB0_2 55.Ltmp1: 56# %bb.1: 57 #DEBUG_VALUE: main:argc <- $edi 58 #DEBUG_VALUE: main:argv <- $rsi 59 pushq %rax 60 .cfi_def_cfa_offset 16 61.Ltmp2: 62 .loc 1 4 3 is_stmt 1 # unreachable.c:4:3 63 movl $.L.str, %edi 64.Ltmp3: 65 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi 66 callq puts 67.Ltmp4: 68 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi 69 .loc 1 0 3 is_stmt 0 # unreachable.c:0:3 70 addq $8, %rsp 71.Ltmp5: 72 .cfi_def_cfa_offset 8 73.LBB0_2: 74 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi 75 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi 76 .loc 1 10 3 is_stmt 1 # unreachable.c:10:3 77 xorl %eax, %eax 78 retq 79.Ltmp6: 80.Lfunc_end0: 81 .size main, .Lfunc_end0-main 82 .cfi_endproc 83 # -- End function 84 .type .L.str,@object # @.str 85 .section .rodata.str1.1,"aMS",@progbits,1 86.L.str: 87 .asciz "hi" 88 .size .L.str, 3 89 90 .section .debug_loc,"",@progbits 91.Ldebug_loc0: 92 .quad .Lfunc_begin0-.Lfunc_begin0 93 .quad .Ltmp3-.Lfunc_begin0 94 .short 1 # Loc expr size 95 .byte 85 # super-register DW_OP_reg5 96 .quad .Ltmp3-.Lfunc_begin0 97 .quad .Lfunc_end0-.Lfunc_begin0 98 .short 4 # Loc expr size 99 .byte 243 # DW_OP_GNU_entry_value 100 .byte 1 # 1 101 .byte 85 # super-register DW_OP_reg5 102 .byte 159 # DW_OP_stack_value 103 .quad 0 104 .quad 0 105.Ldebug_loc1: 106 .quad .Lfunc_begin0-.Lfunc_begin0 107 .quad .Ltmp4-.Lfunc_begin0 108 .short 1 # Loc expr size 109 .byte 84 # DW_OP_reg4 110 .quad .Ltmp4-.Lfunc_begin0 111 .quad .Lfunc_end0-.Lfunc_begin0 112 .short 4 # Loc expr size 113 .byte 243 # DW_OP_GNU_entry_value 114 .byte 1 # 1 115 .byte 84 # DW_OP_reg4 116 .byte 159 # DW_OP_stack_value 117 .quad 0 118 .quad 0 119 .section .debug_abbrev,"",@progbits 120 .byte 1 # Abbreviation Code 121 .byte 17 # DW_TAG_compile_unit 122 .byte 1 # DW_CHILDREN_yes 123 .byte 37 # DW_AT_producer 124 .byte 14 # DW_FORM_strp 125 .byte 19 # DW_AT_language 126 .byte 5 # DW_FORM_data2 127 .byte 3 # DW_AT_name 128 .byte 14 # DW_FORM_strp 129 .byte 16 # DW_AT_stmt_list 130 .byte 23 # DW_FORM_sec_offset 131 .byte 27 # DW_AT_comp_dir 132 .byte 14 # DW_FORM_strp 133 .byte 17 # DW_AT_low_pc 134 .byte 1 # DW_FORM_addr 135 .byte 18 # DW_AT_high_pc 136 .byte 6 # DW_FORM_data4 137 .byte 0 # EOM(1) 138 .byte 0 # EOM(2) 139 .byte 2 # Abbreviation Code 140 .byte 52 # DW_TAG_variable 141 .byte 0 # DW_CHILDREN_no 142 .byte 73 # DW_AT_type 143 .byte 19 # DW_FORM_ref4 144 .byte 58 # DW_AT_decl_file 145 .byte 11 # DW_FORM_data1 146 .byte 59 # DW_AT_decl_line 147 .byte 11 # DW_FORM_data1 148 .byte 2 # DW_AT_location 149 .byte 24 # DW_FORM_exprloc 150 .byte 0 # EOM(1) 151 .byte 0 # EOM(2) 152 .byte 3 # Abbreviation Code 153 .byte 1 # DW_TAG_array_type 154 .byte 1 # DW_CHILDREN_yes 155 .byte 73 # DW_AT_type 156 .byte 19 # DW_FORM_ref4 157 .byte 0 # EOM(1) 158 .byte 0 # EOM(2) 159 .byte 4 # Abbreviation Code 160 .byte 33 # DW_TAG_subrange_type 161 .byte 0 # DW_CHILDREN_no 162 .byte 73 # DW_AT_type 163 .byte 19 # DW_FORM_ref4 164 .byte 55 # DW_AT_count 165 .byte 11 # DW_FORM_data1 166 .byte 0 # EOM(1) 167 .byte 0 # EOM(2) 168 .byte 5 # Abbreviation Code 169 .byte 36 # DW_TAG_base_type 170 .byte 0 # DW_CHILDREN_no 171 .byte 3 # DW_AT_name 172 .byte 14 # DW_FORM_strp 173 .byte 62 # DW_AT_encoding 174 .byte 11 # DW_FORM_data1 175 .byte 11 # DW_AT_byte_size 176 .byte 11 # DW_FORM_data1 177 .byte 0 # EOM(1) 178 .byte 0 # EOM(2) 179 .byte 6 # Abbreviation Code 180 .byte 36 # DW_TAG_base_type 181 .byte 0 # DW_CHILDREN_no 182 .byte 3 # DW_AT_name 183 .byte 14 # DW_FORM_strp 184 .byte 11 # DW_AT_byte_size 185 .byte 11 # DW_FORM_data1 186 .byte 62 # DW_AT_encoding 187 .byte 11 # DW_FORM_data1 188 .byte 0 # EOM(1) 189 .byte 0 # EOM(2) 190 .byte 7 # Abbreviation Code 191 .byte 46 # DW_TAG_subprogram 192 .byte 0 # DW_CHILDREN_no 193 .byte 3 # DW_AT_name 194 .byte 14 # DW_FORM_strp 195 .byte 58 # DW_AT_decl_file 196 .byte 11 # DW_FORM_data1 197 .byte 59 # DW_AT_decl_line 198 .byte 11 # DW_FORM_data1 199 .byte 32 # DW_AT_inline 200 .byte 11 # DW_FORM_data1 201 .byte 0 # EOM(1) 202 .byte 0 # EOM(2) 203 .byte 8 # Abbreviation Code 204 .byte 46 # DW_TAG_subprogram 205 .byte 1 # DW_CHILDREN_yes 206 .byte 17 # DW_AT_low_pc 207 .byte 1 # DW_FORM_addr 208 .byte 18 # DW_AT_high_pc 209 .byte 6 # DW_FORM_data4 210 .byte 64 # DW_AT_frame_base 211 .byte 24 # DW_FORM_exprloc 212 .ascii "\227B" # DW_AT_GNU_all_call_sites 213 .byte 25 # DW_FORM_flag_present 214 .byte 3 # DW_AT_name 215 .byte 14 # DW_FORM_strp 216 .byte 58 # DW_AT_decl_file 217 .byte 11 # DW_FORM_data1 218 .byte 59 # DW_AT_decl_line 219 .byte 11 # DW_FORM_data1 220 .byte 39 # DW_AT_prototyped 221 .byte 25 # DW_FORM_flag_present 222 .byte 73 # DW_AT_type 223 .byte 19 # DW_FORM_ref4 224 .byte 63 # DW_AT_external 225 .byte 25 # DW_FORM_flag_present 226 .byte 0 # EOM(1) 227 .byte 0 # EOM(2) 228 .byte 9 # Abbreviation Code 229 .byte 5 # DW_TAG_formal_parameter 230 .byte 0 # DW_CHILDREN_no 231 .byte 2 # DW_AT_location 232 .byte 23 # DW_FORM_sec_offset 233 .byte 3 # DW_AT_name 234 .byte 14 # DW_FORM_strp 235 .byte 58 # DW_AT_decl_file 236 .byte 11 # DW_FORM_data1 237 .byte 59 # DW_AT_decl_line 238 .byte 11 # DW_FORM_data1 239 .byte 73 # DW_AT_type 240 .byte 19 # DW_FORM_ref4 241 .byte 0 # EOM(1) 242 .byte 0 # EOM(2) 243 .byte 10 # Abbreviation Code 244 .byte 29 # DW_TAG_inlined_subroutine 245 .byte 0 # DW_CHILDREN_no 246 .byte 49 # DW_AT_abstract_origin 247 .byte 19 # DW_FORM_ref4 248 .byte 17 # DW_AT_low_pc 249 .byte 1 # DW_FORM_addr 250 .byte 18 # DW_AT_high_pc 251 .byte 6 # DW_FORM_data4 252 .byte 88 # DW_AT_call_file 253 .byte 11 # DW_FORM_data1 254 .byte 89 # DW_AT_call_line 255 .byte 11 # DW_FORM_data1 256 .byte 87 # DW_AT_call_column 257 .byte 11 # DW_FORM_data1 258 .byte 0 # EOM(1) 259 .byte 0 # EOM(2) 260 .byte 11 # Abbreviation Code 261 .ascii "\211\202\001" # DW_TAG_GNU_call_site 262 .byte 0 # DW_CHILDREN_no 263 .byte 49 # DW_AT_abstract_origin 264 .byte 19 # DW_FORM_ref4 265 .byte 17 # DW_AT_low_pc 266 .byte 1 # DW_FORM_addr 267 .byte 0 # EOM(1) 268 .byte 0 # EOM(2) 269 .byte 12 # Abbreviation Code 270 .byte 46 # DW_TAG_subprogram 271 .byte 1 # DW_CHILDREN_yes 272 .byte 3 # DW_AT_name 273 .byte 14 # DW_FORM_strp 274 .byte 58 # DW_AT_decl_file 275 .byte 11 # DW_FORM_data1 276 .byte 59 # DW_AT_decl_line 277 .byte 11 # DW_FORM_data1 278 .byte 39 # DW_AT_prototyped 279 .byte 25 # DW_FORM_flag_present 280 .byte 60 # DW_AT_declaration 281 .byte 25 # DW_FORM_flag_present 282 .byte 63 # DW_AT_external 283 .byte 25 # DW_FORM_flag_present 284 .byte 0 # EOM(1) 285 .byte 0 # EOM(2) 286 .byte 13 # Abbreviation Code 287 .byte 5 # DW_TAG_formal_parameter 288 .byte 0 # DW_CHILDREN_no 289 .byte 73 # DW_AT_type 290 .byte 19 # DW_FORM_ref4 291 .byte 0 # EOM(1) 292 .byte 0 # EOM(2) 293 .byte 14 # Abbreviation Code 294 .byte 15 # DW_TAG_pointer_type 295 .byte 0 # DW_CHILDREN_no 296 .byte 73 # DW_AT_type 297 .byte 19 # DW_FORM_ref4 298 .byte 0 # EOM(1) 299 .byte 0 # EOM(2) 300 .byte 15 # Abbreviation Code 301 .byte 38 # DW_TAG_const_type 302 .byte 0 # DW_CHILDREN_no 303 .byte 73 # DW_AT_type 304 .byte 19 # DW_FORM_ref4 305 .byte 0 # EOM(1) 306 .byte 0 # EOM(2) 307 .byte 0 # EOM(3) 308 .section .debug_info,"",@progbits 309.Lcu_begin0: 310 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 311.Ldebug_info_start0: 312 .short 4 # DWARF version number 313 .long .debug_abbrev # Offset Into Abbrev. Section 314 .byte 8 # Address Size (in bytes) 315 .byte 1 # Abbrev [1] 0xb:0xd4 DW_TAG_compile_unit 316 .long .Linfo_string0 # DW_AT_producer 317 .short 12 # DW_AT_language 318 .long .Linfo_string1 # DW_AT_name 319 .long .Lline_table_start0 # DW_AT_stmt_list 320 .long .Linfo_string2 # DW_AT_comp_dir 321 .quad .Lfunc_begin0 # DW_AT_low_pc 322 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 323 .byte 2 # Abbrev [2] 0x2a:0x11 DW_TAG_variable 324 .long 59 # DW_AT_type 325 .byte 1 # DW_AT_decl_file 326 .byte 4 # DW_AT_decl_line 327 .byte 9 # DW_AT_location 328 .byte 3 329 .quad .L.str 330 .byte 3 # Abbrev [3] 0x3b:0xc DW_TAG_array_type 331 .long 71 # DW_AT_type 332 .byte 4 # Abbrev [4] 0x40:0x6 DW_TAG_subrange_type 333 .long 78 # DW_AT_type 334 .byte 3 # DW_AT_count 335 .byte 0 # End Of Children Mark 336 .byte 5 # Abbrev [5] 0x47:0x7 DW_TAG_base_type 337 .long .Linfo_string3 # DW_AT_name 338 .byte 6 # DW_AT_encoding 339 .byte 1 # DW_AT_byte_size 340 .byte 6 # Abbrev [6] 0x4e:0x7 DW_TAG_base_type 341 .long .Linfo_string4 # DW_AT_name 342 .byte 8 # DW_AT_byte_size 343 .byte 7 # DW_AT_encoding 344 .byte 7 # Abbrev [7] 0x55:0x8 DW_TAG_subprogram 345 .long .Linfo_string5 # DW_AT_name 346 .byte 1 # DW_AT_decl_file 347 .byte 3 # DW_AT_decl_line 348 .byte 1 # DW_AT_inline 349 .byte 8 # Abbrev [8] 0x5d:0x59 DW_TAG_subprogram 350 .quad .Lfunc_begin0 # DW_AT_low_pc 351 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 352 .byte 1 # DW_AT_frame_base 353 .byte 87 354 # DW_AT_GNU_all_call_sites 355 .long .Linfo_string7 # DW_AT_name 356 .byte 1 # DW_AT_decl_file 357 .byte 7 # DW_AT_decl_line 358 # DW_AT_prototyped 359 .long 205 # DW_AT_type 360 # DW_AT_external 361 .byte 9 # Abbrev [9] 0x76:0xf DW_TAG_formal_parameter 362 .long .Ldebug_loc0 # DW_AT_location 363 .long .Linfo_string9 # DW_AT_name 364 .byte 1 # DW_AT_decl_file 365 .byte 7 # DW_AT_decl_line 366 .long 205 # DW_AT_type 367 .byte 9 # Abbrev [9] 0x85:0xf DW_TAG_formal_parameter 368 .long .Ldebug_loc1 # DW_AT_location 369 .long .Linfo_string10 # DW_AT_name 370 .byte 1 # DW_AT_decl_file 371 .byte 7 # DW_AT_decl_line 372 .long 212 # DW_AT_type 373 .byte 10 # Abbrev [10] 0x94:0x14 DW_TAG_inlined_subroutine 374 .long 85 # DW_AT_abstract_origin 375 .quad .Ltmp2 # DW_AT_low_pc 376 .long .Ltmp5-.Ltmp2 # DW_AT_high_pc 377 .byte 1 # DW_AT_call_file 378 .byte 9 # DW_AT_call_line 379 .byte 5 # DW_AT_call_column 380 .byte 11 # Abbrev [11] 0xa8:0xd DW_TAG_GNU_call_site 381 .long 182 # DW_AT_abstract_origin 382 .quad .Ltmp4 # DW_AT_low_pc 383 .byte 0 # End Of Children Mark 384 .byte 12 # Abbrev [12] 0xb6:0xd DW_TAG_subprogram 385 .long .Linfo_string6 # DW_AT_name 386 .byte 1 # DW_AT_decl_file 387 .byte 1 # DW_AT_decl_line 388 # DW_AT_prototyped 389 # DW_AT_declaration 390 # DW_AT_external 391 .byte 13 # Abbrev [13] 0xbd:0x5 DW_TAG_formal_parameter 392 .long 195 # DW_AT_type 393 .byte 0 # End Of Children Mark 394 .byte 14 # Abbrev [14] 0xc3:0x5 DW_TAG_pointer_type 395 .long 200 # DW_AT_type 396 .byte 15 # Abbrev [15] 0xc8:0x5 DW_TAG_const_type 397 .long 71 # DW_AT_type 398 .byte 5 # Abbrev [5] 0xcd:0x7 DW_TAG_base_type 399 .long .Linfo_string8 # DW_AT_name 400 .byte 5 # DW_AT_encoding 401 .byte 4 # DW_AT_byte_size 402 .byte 14 # Abbrev [14] 0xd4:0x5 DW_TAG_pointer_type 403 .long 217 # DW_AT_type 404 .byte 14 # Abbrev [14] 0xd9:0x5 DW_TAG_pointer_type 405 .long 71 # DW_AT_type 406 .byte 0 # End Of Children Mark 407.Ldebug_info_end0: 408 .section .debug_str,"MS",@progbits,1 409.Linfo_string0: 410 .asciz "clang version 15.0.7 " # string offset=0 411.Linfo_string1: 412 .asciz "unreachable.c" # string offset=69 413.Linfo_string2: 414 .asciz "." # string offset=83 415.Linfo_string3: 416 .asciz "char" # string offset=85 417.Linfo_string4: 418 .asciz "__ARRAY_SIZE_TYPE__" # string offset=90 419.Linfo_string5: 420 .asciz "foo" # string offset=110 421.Linfo_string6: 422 .asciz "puts" # string offset=114 423.Linfo_string7: 424 .asciz "main" # string offset=119 425.Linfo_string8: 426 .asciz "int" # string offset=124 427.Linfo_string9: 428 .asciz "argc" # string offset=128 429.Linfo_string10: 430 .asciz "argv" # string offset=133 431 .section .debug_line,"",@progbits 432.Lline_table_start0: 433