485 lines · plain
1# REQUIRES: system-linux2 3# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o4# RUN: %clang %cflags -no-pie %s -o %t.exe -Wl,-q5# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections6# RUN: llvm-dwarfdump --show-children --name=main --debug-info %t.bolt \7# RUN: | FileCheck %s8 9# CHECK: DW_TAG_inlined_subroutine10# CHECK: DW_AT_low_pc11# CHECK-SAME: 0x000000000000000012 13# CHECK: DW_TAG_call_site14# CHECK: DW_AT_call_return_pc15# CHECK-SAME: 0x000000000000000016 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 -gdwarf-5 ...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 .text38 .file "unreachable.c"39 .file 0 "." "unreachable.c" md5 0xd268d8460ea246544a440d4d4223594740 .globl main # -- Begin function main41 .p2align 4, 0x9042 .type main,@function43main: # @main44.Lfunc_begin0:45 .loc 0 7 0 # unreachable.c:7:046 .cfi_startproc47# %bb.0:48 #DEBUG_VALUE: main:argc <- $edi49 #DEBUG_VALUE: main:argv <- $rsi50 .loc 0 8 7 prologue_end # unreachable.c:8:751 testl %edi, %edi52.Ltmp0:53 .loc 0 8 7 is_stmt 0 # unreachable.c:8:754 jmp .LBB0_255.Ltmp1:56# %bb.1:57 #DEBUG_VALUE: main:argc <- $edi58 #DEBUG_VALUE: main:argv <- $rsi59 pushq %rax60 .cfi_def_cfa_offset 1661.Ltmp2:62 .loc 0 4 3 is_stmt 1 # unreachable.c:4:363 movl $.L.str, %edi64.Ltmp3:65 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi66 callq puts67.Ltmp4:68 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi69 .loc 0 0 3 is_stmt 0 # unreachable.c:0:370 addq $8, %rsp71.Ltmp5:72 .cfi_def_cfa_offset 873.LBB0_2:74 #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $edi75 #DEBUG_VALUE: main:argv <- [DW_OP_LLVM_entry_value 1] $rsi76 .loc 0 10 3 is_stmt 1 # unreachable.c:10:377 xorl %eax, %eax78 retq79.Ltmp6:80.Lfunc_end0:81 .size main, .Lfunc_end0-main82 .cfi_endproc83 # -- End function84 .type .L.str,@object # @.str85 .section .rodata.str1.1,"aMS",@progbits,186.L.str:87 .asciz "hi"88 .size .L.str, 389 90 .section .debug_loclists,"",@progbits91 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length92.Ldebug_list_header_start0:93 .short 5 # Version94 .byte 8 # Address size95 .byte 0 # Segment selector size96 .long 2 # Offset entry count97.Lloclists_table_base0:98 .long .Ldebug_loc0-.Lloclists_table_base099 .long .Ldebug_loc1-.Lloclists_table_base0100.Ldebug_loc0:101 .byte 4 # DW_LLE_offset_pair102 .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset103 .uleb128 .Ltmp3-.Lfunc_begin0 # ending offset104 .byte 1 # Loc expr size105 .byte 85 # super-register DW_OP_reg5106 .byte 4 # DW_LLE_offset_pair107 .uleb128 .Ltmp3-.Lfunc_begin0 # starting offset108 .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset109 .byte 4 # Loc expr size110 .byte 163 # DW_OP_entry_value111 .byte 1 # 1112 .byte 85 # super-register DW_OP_reg5113 .byte 159 # DW_OP_stack_value114 .byte 0 # DW_LLE_end_of_list115.Ldebug_loc1:116 .byte 4 # DW_LLE_offset_pair117 .uleb128 .Lfunc_begin0-.Lfunc_begin0 # starting offset118 .uleb128 .Ltmp4-.Lfunc_begin0 # ending offset119 .byte 1 # Loc expr size120 .byte 84 # DW_OP_reg4121 .byte 4 # DW_LLE_offset_pair122 .uleb128 .Ltmp4-.Lfunc_begin0 # starting offset123 .uleb128 .Lfunc_end0-.Lfunc_begin0 # ending offset124 .byte 4 # Loc expr size125 .byte 163 # DW_OP_entry_value126 .byte 1 # 1127 .byte 84 # DW_OP_reg4128 .byte 159 # DW_OP_stack_value129 .byte 0 # DW_LLE_end_of_list130.Ldebug_list_header_end0:131 .section .debug_abbrev,"",@progbits132 .byte 1 # Abbreviation Code133 .byte 17 # DW_TAG_compile_unit134 .byte 1 # DW_CHILDREN_yes135 .byte 37 # DW_AT_producer136 .byte 37 # DW_FORM_strx1137 .byte 19 # DW_AT_language138 .byte 5 # DW_FORM_data2139 .byte 3 # DW_AT_name140 .byte 37 # DW_FORM_strx1141 .byte 114 # DW_AT_str_offsets_base142 .byte 23 # DW_FORM_sec_offset143 .byte 16 # DW_AT_stmt_list144 .byte 23 # DW_FORM_sec_offset145 .byte 27 # DW_AT_comp_dir146 .byte 37 # DW_FORM_strx1147 .byte 17 # DW_AT_low_pc148 .byte 27 # DW_FORM_addrx149 .byte 18 # DW_AT_high_pc150 .byte 6 # DW_FORM_data4151 .byte 115 # DW_AT_addr_base152 .byte 23 # DW_FORM_sec_offset153 .ascii "\214\001" # DW_AT_loclists_base154 .byte 23 # DW_FORM_sec_offset155 .byte 0 # EOM(1)156 .byte 0 # EOM(2)157 .byte 2 # Abbreviation Code158 .byte 52 # DW_TAG_variable159 .byte 0 # DW_CHILDREN_no160 .byte 73 # DW_AT_type161 .byte 19 # DW_FORM_ref4162 .byte 58 # DW_AT_decl_file163 .byte 11 # DW_FORM_data1164 .byte 59 # DW_AT_decl_line165 .byte 11 # DW_FORM_data1166 .byte 2 # DW_AT_location167 .byte 24 # DW_FORM_exprloc168 .byte 0 # EOM(1)169 .byte 0 # EOM(2)170 .byte 3 # Abbreviation Code171 .byte 1 # DW_TAG_array_type172 .byte 1 # DW_CHILDREN_yes173 .byte 73 # DW_AT_type174 .byte 19 # DW_FORM_ref4175 .byte 0 # EOM(1)176 .byte 0 # EOM(2)177 .byte 4 # Abbreviation Code178 .byte 33 # DW_TAG_subrange_type179 .byte 0 # DW_CHILDREN_no180 .byte 73 # DW_AT_type181 .byte 19 # DW_FORM_ref4182 .byte 55 # DW_AT_count183 .byte 11 # DW_FORM_data1184 .byte 0 # EOM(1)185 .byte 0 # EOM(2)186 .byte 5 # Abbreviation Code187 .byte 36 # DW_TAG_base_type188 .byte 0 # DW_CHILDREN_no189 .byte 3 # DW_AT_name190 .byte 37 # DW_FORM_strx1191 .byte 62 # DW_AT_encoding192 .byte 11 # DW_FORM_data1193 .byte 11 # DW_AT_byte_size194 .byte 11 # DW_FORM_data1195 .byte 0 # EOM(1)196 .byte 0 # EOM(2)197 .byte 6 # Abbreviation Code198 .byte 36 # DW_TAG_base_type199 .byte 0 # DW_CHILDREN_no200 .byte 3 # DW_AT_name201 .byte 37 # DW_FORM_strx1202 .byte 11 # DW_AT_byte_size203 .byte 11 # DW_FORM_data1204 .byte 62 # DW_AT_encoding205 .byte 11 # DW_FORM_data1206 .byte 0 # EOM(1)207 .byte 0 # EOM(2)208 .byte 7 # Abbreviation Code209 .byte 46 # DW_TAG_subprogram210 .byte 0 # DW_CHILDREN_no211 .byte 3 # DW_AT_name212 .byte 37 # DW_FORM_strx1213 .byte 58 # DW_AT_decl_file214 .byte 11 # DW_FORM_data1215 .byte 59 # DW_AT_decl_line216 .byte 11 # DW_FORM_data1217 .byte 32 # DW_AT_inline218 .byte 33 # DW_FORM_implicit_const219 .byte 1220 .byte 0 # EOM(1)221 .byte 0 # EOM(2)222 .byte 8 # Abbreviation Code223 .byte 46 # DW_TAG_subprogram224 .byte 1 # DW_CHILDREN_yes225 .byte 17 # DW_AT_low_pc226 .byte 27 # DW_FORM_addrx227 .byte 18 # DW_AT_high_pc228 .byte 6 # DW_FORM_data4229 .byte 64 # DW_AT_frame_base230 .byte 24 # DW_FORM_exprloc231 .byte 122 # DW_AT_call_all_calls232 .byte 25 # DW_FORM_flag_present233 .byte 3 # DW_AT_name234 .byte 37 # DW_FORM_strx1235 .byte 58 # DW_AT_decl_file236 .byte 11 # DW_FORM_data1237 .byte 59 # DW_AT_decl_line238 .byte 11 # DW_FORM_data1239 .byte 39 # DW_AT_prototyped240 .byte 25 # DW_FORM_flag_present241 .byte 73 # DW_AT_type242 .byte 19 # DW_FORM_ref4243 .byte 63 # DW_AT_external244 .byte 25 # DW_FORM_flag_present245 .byte 0 # EOM(1)246 .byte 0 # EOM(2)247 .byte 9 # Abbreviation Code248 .byte 5 # DW_TAG_formal_parameter249 .byte 0 # DW_CHILDREN_no250 .byte 2 # DW_AT_location251 .byte 34 # DW_FORM_loclistx252 .byte 3 # DW_AT_name253 .byte 37 # DW_FORM_strx1254 .byte 58 # DW_AT_decl_file255 .byte 11 # DW_FORM_data1256 .byte 59 # DW_AT_decl_line257 .byte 11 # DW_FORM_data1258 .byte 73 # DW_AT_type259 .byte 19 # DW_FORM_ref4260 .byte 0 # EOM(1)261 .byte 0 # EOM(2)262 .byte 10 # Abbreviation Code263 .byte 29 # DW_TAG_inlined_subroutine264 .byte 0 # DW_CHILDREN_no265 .byte 49 # DW_AT_abstract_origin266 .byte 19 # DW_FORM_ref4267 .byte 17 # DW_AT_low_pc268 .byte 27 # DW_FORM_addrx269 .byte 18 # DW_AT_high_pc270 .byte 6 # DW_FORM_data4271 .byte 88 # DW_AT_call_file272 .byte 11 # DW_FORM_data1273 .byte 89 # DW_AT_call_line274 .byte 11 # DW_FORM_data1275 .byte 87 # DW_AT_call_column276 .byte 11 # DW_FORM_data1277 .byte 0 # EOM(1)278 .byte 0 # EOM(2)279 .byte 11 # Abbreviation Code280 .byte 72 # DW_TAG_call_site281 .byte 0 # DW_CHILDREN_no282 .byte 127 # DW_AT_call_origin283 .byte 19 # DW_FORM_ref4284 .byte 125 # DW_AT_call_return_pc285 .byte 27 # DW_FORM_addrx286 .byte 0 # EOM(1)287 .byte 0 # EOM(2)288 .byte 12 # Abbreviation Code289 .byte 46 # DW_TAG_subprogram290 .byte 1 # DW_CHILDREN_yes291 .byte 3 # DW_AT_name292 .byte 37 # DW_FORM_strx1293 .byte 58 # DW_AT_decl_file294 .byte 11 # DW_FORM_data1295 .byte 59 # DW_AT_decl_line296 .byte 11 # DW_FORM_data1297 .byte 39 # DW_AT_prototyped298 .byte 25 # DW_FORM_flag_present299 .byte 60 # DW_AT_declaration300 .byte 25 # DW_FORM_flag_present301 .byte 63 # DW_AT_external302 .byte 25 # DW_FORM_flag_present303 .byte 0 # EOM(1)304 .byte 0 # EOM(2)305 .byte 13 # Abbreviation Code306 .byte 5 # DW_TAG_formal_parameter307 .byte 0 # DW_CHILDREN_no308 .byte 73 # DW_AT_type309 .byte 19 # DW_FORM_ref4310 .byte 0 # EOM(1)311 .byte 0 # EOM(2)312 .byte 14 # Abbreviation Code313 .byte 15 # DW_TAG_pointer_type314 .byte 0 # DW_CHILDREN_no315 .byte 73 # DW_AT_type316 .byte 19 # DW_FORM_ref4317 .byte 0 # EOM(1)318 .byte 0 # EOM(2)319 .byte 15 # Abbreviation Code320 .byte 38 # DW_TAG_const_type321 .byte 0 # DW_CHILDREN_no322 .byte 73 # DW_AT_type323 .byte 19 # DW_FORM_ref4324 .byte 0 # EOM(1)325 .byte 0 # EOM(2)326 .byte 0 # EOM(3)327 .section .debug_info,"",@progbits328.Lcu_begin0:329 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit330.Ldebug_info_start0:331 .short 5 # DWARF version number332 .byte 1 # DWARF Unit Type333 .byte 8 # Address Size (in bytes)334 .long .debug_abbrev # Offset Into Abbrev. Section335 .byte 1 # Abbrev [1] 0xc:0x95 DW_TAG_compile_unit336 .byte 0 # DW_AT_producer337 .short 12 # DW_AT_language338 .byte 1 # DW_AT_name339 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base340 .long .Lline_table_start0 # DW_AT_stmt_list341 .byte 2 # DW_AT_comp_dir342 .byte 1 # DW_AT_low_pc343 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc344 .long .Laddr_table_base0 # DW_AT_addr_base345 .long .Lloclists_table_base0 # DW_AT_loclists_base346 .byte 2 # Abbrev [2] 0x27:0xa DW_TAG_variable347 .long 49 # DW_AT_type348 .byte 0 # DW_AT_decl_file349 .byte 4 # DW_AT_decl_line350 .byte 2 # DW_AT_location351 .byte 161352 .byte 0353 .byte 3 # Abbrev [3] 0x31:0xc DW_TAG_array_type354 .long 61 # DW_AT_type355 .byte 4 # Abbrev [4] 0x36:0x6 DW_TAG_subrange_type356 .long 65 # DW_AT_type357 .byte 3 # DW_AT_count358 .byte 0 # End Of Children Mark359 .byte 5 # Abbrev [5] 0x3d:0x4 DW_TAG_base_type360 .byte 3 # DW_AT_name361 .byte 6 # DW_AT_encoding362 .byte 1 # DW_AT_byte_size363 .byte 6 # Abbrev [6] 0x41:0x4 DW_TAG_base_type364 .byte 4 # DW_AT_name365 .byte 8 # DW_AT_byte_size366 .byte 7 # DW_AT_encoding367 .byte 7 # Abbrev [7] 0x45:0x4 DW_TAG_subprogram368 .byte 5 # DW_AT_name369 .byte 0 # DW_AT_decl_file370 .byte 3 # DW_AT_decl_line371 # DW_AT_inline372 .byte 8 # Abbrev [8] 0x49:0x35 DW_TAG_subprogram373 .byte 1 # DW_AT_low_pc374 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc375 .byte 1 # DW_AT_frame_base376 .byte 87377 # DW_AT_call_all_calls378 .byte 7 # DW_AT_name379 .byte 0 # DW_AT_decl_file380 .byte 7 # DW_AT_decl_line381 # DW_AT_prototyped382 .long 146 # DW_AT_type383 # DW_AT_external384 .byte 9 # Abbrev [9] 0x58:0x9 DW_TAG_formal_parameter385 .byte 0 # DW_AT_location386 .byte 9 # DW_AT_name387 .byte 0 # DW_AT_decl_file388 .byte 7 # DW_AT_decl_line389 .long 146 # DW_AT_type390 .byte 9 # Abbrev [9] 0x61:0x9 DW_TAG_formal_parameter391 .byte 1 # DW_AT_location392 .byte 10 # DW_AT_name393 .byte 0 # DW_AT_decl_file394 .byte 7 # DW_AT_decl_line395 .long 150 # DW_AT_type396 .byte 10 # Abbrev [10] 0x6a:0xd DW_TAG_inlined_subroutine397 .long 69 # DW_AT_abstract_origin398 .byte 2 # DW_AT_low_pc399 .long .Ltmp5-.Ltmp2 # DW_AT_high_pc400 .byte 0 # DW_AT_call_file401 .byte 9 # DW_AT_call_line402 .byte 5 # DW_AT_call_column403 .byte 11 # Abbrev [11] 0x77:0x6 DW_TAG_call_site404 .long 126 # DW_AT_call_origin405 .byte 3 # DW_AT_call_return_pc406 .byte 0 # End Of Children Mark407 .byte 12 # Abbrev [12] 0x7e:0xa DW_TAG_subprogram408 .byte 6 # DW_AT_name409 .byte 0 # DW_AT_decl_file410 .byte 1 # DW_AT_decl_line411 # DW_AT_prototyped412 # DW_AT_declaration413 # DW_AT_external414 .byte 13 # Abbrev [13] 0x82:0x5 DW_TAG_formal_parameter415 .long 136 # DW_AT_type416 .byte 0 # End Of Children Mark417 .byte 14 # Abbrev [14] 0x88:0x5 DW_TAG_pointer_type418 .long 141 # DW_AT_type419 .byte 15 # Abbrev [15] 0x8d:0x5 DW_TAG_const_type420 .long 61 # DW_AT_type421 .byte 5 # Abbrev [5] 0x92:0x4 DW_TAG_base_type422 .byte 8 # DW_AT_name423 .byte 5 # DW_AT_encoding424 .byte 4 # DW_AT_byte_size425 .byte 14 # Abbrev [14] 0x96:0x5 DW_TAG_pointer_type426 .long 155 # DW_AT_type427 .byte 14 # Abbrev [14] 0x9b:0x5 DW_TAG_pointer_type428 .long 61 # DW_AT_type429 .byte 0 # End Of Children Mark430.Ldebug_info_end0:431 .section .debug_str_offsets,"",@progbits432 .long 48 # Length of String Offsets Set433 .short 5434 .short 0435.Lstr_offsets_base0:436 .section .debug_str,"MS",@progbits,1437.Linfo_string0:438 .asciz "clang version 15.0.7 " # string offset=0439.Linfo_string1:440 .asciz "unreachable.c" # string offset=69441.Linfo_string2:442 .asciz "." # string offset=83443.Linfo_string3:444 .asciz "char" # string offset=85445.Linfo_string4:446 .asciz "__ARRAY_SIZE_TYPE__" # string offset=90447.Linfo_string5:448 .asciz "foo" # string offset=110449.Linfo_string6:450 .asciz "puts" # string offset=114451.Linfo_string7:452 .asciz "main" # string offset=119453.Linfo_string8:454 .asciz "int" # string offset=124455.Linfo_string9:456 .asciz "argc" # string offset=128457.Linfo_string10:458 .asciz "argv" # string offset=133459 .section .debug_str_offsets,"",@progbits460 .long .Linfo_string0461 .long .Linfo_string1462 .long .Linfo_string2463 .long .Linfo_string3464 .long .Linfo_string4465 .long .Linfo_string5466 .long .Linfo_string6467 .long .Linfo_string7468 .long .Linfo_string8469 .long .Linfo_string9470 .long .Linfo_string10471 .section .debug_addr,"",@progbits472 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution473.Ldebug_addr_start0:474 .short 5 # DWARF version number475 .byte 8 # Address size476 .byte 0 # Segment selector size477.Laddr_table_base0:478 .quad .L.str479 .quad .Lfunc_begin0480 .quad .Ltmp2481 .quad .Ltmp4482.Ldebug_addr_end0:483 .section .debug_line,"",@progbits484.Lline_table_start0:485