385 lines · plain
1 2# REQUIRES: system-linux3 4# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o5# RUN: %clang %cflags -dwarf-4 %t1.o -o %t.exe6# RUN: llvm-objcopy --remove-section=.debug_loc %t.exe7# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections &> file8# RUN: cat file | FileCheck --check-prefix=CHECK %s9 10## Making sure we handle error returned by visitLocationList correctly.11 12# CHECK: BOLT-WARNING: empty location list detected at13# CHECK-NEXT: BOLT-WARNING: empty location list detected at14# CHECK-NEXT: BOLT:15 16# clang++ main.cpp -g -ffunction-sections -Os -gdwarf-4 -S17# int doStuff2(int val) {18# return val += 3;19# }20#21# int main(int argc, const char** argv) {22# return doStuff2(argc);23# }24 25 .text26 .file "main.cpp"27 .section .text._Z8doStuff2i,"ax",@progbits28 .globl _Z8doStuff2i # -- Begin function _Z8doStuff2i29 .type _Z8doStuff2i,@function30_Z8doStuff2i: # @_Z8doStuff2i31.Lfunc_begin0:32 .file 1 "." "main.cpp"33 .loc 1 2 0 # main.cpp:2:034 .cfi_startproc35# %bb.0: # %entry36 #DEBUG_VALUE: doStuff2:val <- $edi37 # kill: def $edi killed $edi def $rdi38 .loc 1 3 14 prologue_end # main.cpp:3:1439 leal 3(%rdi), %eax40.Ltmp0:41 #DEBUG_VALUE: doStuff2:val <- $eax42 .loc 1 3 3 is_stmt 0 # main.cpp:3:343 retq44.Ltmp1:45.Lfunc_end0:46 .size _Z8doStuff2i, .Lfunc_end0-_Z8doStuff2i47 .cfi_endproc48 # -- End function49 .section .text.main,"ax",@progbits50 .globl main # -- Begin function main51 .type main,@function52main: # @main53.Lfunc_begin1:54 .loc 1 6 0 is_stmt 1 # main.cpp:6:055 .cfi_startproc56# %bb.0: # %entry57 #DEBUG_VALUE: main:argc <- $edi58 #DEBUG_VALUE: main:argv <- $rsi59 #DEBUG_VALUE: doStuff2:val <- $edi60 # kill: def $edi killed $edi def $rdi61 .loc 1 3 14 prologue_end # main.cpp:3:1462 leal 3(%rdi), %eax63.Ltmp2:64 #DEBUG_VALUE: doStuff2:val <- $eax65 .loc 1 7 3 # main.cpp:7:366 retq67.Ltmp3:68.Lfunc_end1:69 .size main, .Lfunc_end1-main70 .cfi_endproc71 # -- End function72 .section .debug_loc,"",@progbits73.Ldebug_loc0:74 .quad -175 .quad .Lfunc_begin0 # base address76 .quad .Lfunc_begin0-.Lfunc_begin077 .quad .Ltmp0-.Lfunc_begin078 .short 1 # Loc expr size79 .byte 85 # super-register DW_OP_reg580 .quad .Ltmp0-.Lfunc_begin081 .quad .Lfunc_end0-.Lfunc_begin082 .short 1 # Loc expr size83 .byte 80 # super-register DW_OP_reg084 .quad 085 .quad 086.Ldebug_loc1:87 .quad -188 .quad .Lfunc_begin1 # base address89 .quad .Lfunc_begin1-.Lfunc_begin190 .quad .Ltmp2-.Lfunc_begin191 .short 1 # Loc expr size92 .byte 85 # super-register DW_OP_reg593 .quad .Ltmp2-.Lfunc_begin194 .quad .Lfunc_end1-.Lfunc_begin195 .short 1 # Loc expr size96 .byte 80 # super-register DW_OP_reg097 .quad 098 .quad 099 .section .debug_abbrev,"",@progbits100 .byte 1 # Abbreviation Code101 .byte 17 # DW_TAG_compile_unit102 .byte 1 # DW_CHILDREN_yes103 .byte 37 # DW_AT_producer104 .byte 14 # DW_FORM_strp105 .byte 19 # DW_AT_language106 .byte 5 # DW_FORM_data2107 .byte 3 # DW_AT_name108 .byte 14 # DW_FORM_strp109 .byte 16 # DW_AT_stmt_list110 .byte 23 # DW_FORM_sec_offset111 .byte 27 # DW_AT_comp_dir112 .byte 14 # DW_FORM_strp113 .byte 17 # DW_AT_low_pc114 .byte 1 # DW_FORM_addr115 .byte 85 # DW_AT_ranges116 .byte 23 # DW_FORM_sec_offset117 .byte 0 # EOM(1)118 .byte 0 # EOM(2)119 .byte 2 # Abbreviation Code120 .byte 46 # DW_TAG_subprogram121 .byte 1 # DW_CHILDREN_yes122 .byte 17 # DW_AT_low_pc123 .byte 1 # DW_FORM_addr124 .byte 18 # DW_AT_high_pc125 .byte 6 # DW_FORM_data4126 .byte 64 # DW_AT_frame_base127 .byte 24 # DW_FORM_exprloc128 .ascii "\227B" # DW_AT_GNU_all_call_sites129 .byte 25 # DW_FORM_flag_present130 .byte 49 # DW_AT_abstract_origin131 .byte 19 # DW_FORM_ref4132 .byte 0 # EOM(1)133 .byte 0 # EOM(2)134 .byte 3 # Abbreviation Code135 .byte 5 # DW_TAG_formal_parameter136 .byte 0 # DW_CHILDREN_no137 .byte 2 # DW_AT_location138 .byte 23 # DW_FORM_sec_offset139 .byte 49 # DW_AT_abstract_origin140 .byte 19 # DW_FORM_ref4141 .byte 0 # EOM(1)142 .byte 0 # EOM(2)143 .byte 4 # Abbreviation Code144 .byte 46 # DW_TAG_subprogram145 .byte 1 # DW_CHILDREN_yes146 .byte 110 # DW_AT_linkage_name147 .byte 14 # DW_FORM_strp148 .byte 3 # DW_AT_name149 .byte 14 # DW_FORM_strp150 .byte 58 # DW_AT_decl_file151 .byte 11 # DW_FORM_data1152 .byte 59 # DW_AT_decl_line153 .byte 11 # DW_FORM_data1154 .byte 73 # DW_AT_type155 .byte 19 # DW_FORM_ref4156 .byte 63 # DW_AT_external157 .byte 25 # DW_FORM_flag_present158 .byte 32 # DW_AT_inline159 .byte 11 # DW_FORM_data1160 .byte 0 # EOM(1)161 .byte 0 # EOM(2)162 .byte 5 # Abbreviation Code163 .byte 5 # DW_TAG_formal_parameter164 .byte 0 # DW_CHILDREN_no165 .byte 3 # DW_AT_name166 .byte 14 # DW_FORM_strp167 .byte 58 # DW_AT_decl_file168 .byte 11 # DW_FORM_data1169 .byte 59 # DW_AT_decl_line170 .byte 11 # DW_FORM_data1171 .byte 73 # DW_AT_type172 .byte 19 # DW_FORM_ref4173 .byte 0 # EOM(1)174 .byte 0 # EOM(2)175 .byte 6 # Abbreviation Code176 .byte 36 # DW_TAG_base_type177 .byte 0 # DW_CHILDREN_no178 .byte 3 # DW_AT_name179 .byte 14 # DW_FORM_strp180 .byte 62 # DW_AT_encoding181 .byte 11 # DW_FORM_data1182 .byte 11 # DW_AT_byte_size183 .byte 11 # DW_FORM_data1184 .byte 0 # EOM(1)185 .byte 0 # EOM(2)186 .byte 7 # Abbreviation Code187 .byte 46 # DW_TAG_subprogram188 .byte 1 # DW_CHILDREN_yes189 .byte 17 # DW_AT_low_pc190 .byte 1 # DW_FORM_addr191 .byte 18 # DW_AT_high_pc192 .byte 6 # DW_FORM_data4193 .byte 64 # DW_AT_frame_base194 .byte 24 # DW_FORM_exprloc195 .ascii "\227B" # DW_AT_GNU_all_call_sites196 .byte 25 # DW_FORM_flag_present197 .byte 3 # DW_AT_name198 .byte 14 # DW_FORM_strp199 .byte 58 # DW_AT_decl_file200 .byte 11 # DW_FORM_data1201 .byte 59 # DW_AT_decl_line202 .byte 11 # DW_FORM_data1203 .byte 73 # DW_AT_type204 .byte 19 # DW_FORM_ref4205 .byte 63 # DW_AT_external206 .byte 25 # DW_FORM_flag_present207 .byte 0 # EOM(1)208 .byte 0 # EOM(2)209 .byte 8 # Abbreviation Code210 .byte 5 # DW_TAG_formal_parameter211 .byte 0 # DW_CHILDREN_no212 .byte 2 # DW_AT_location213 .byte 24 # DW_FORM_exprloc214 .byte 3 # DW_AT_name215 .byte 14 # DW_FORM_strp216 .byte 58 # DW_AT_decl_file217 .byte 11 # DW_FORM_data1218 .byte 59 # DW_AT_decl_line219 .byte 11 # DW_FORM_data1220 .byte 73 # DW_AT_type221 .byte 19 # DW_FORM_ref4222 .byte 0 # EOM(1)223 .byte 0 # EOM(2)224 .byte 9 # Abbreviation Code225 .byte 29 # DW_TAG_inlined_subroutine226 .byte 1 # DW_CHILDREN_yes227 .byte 49 # DW_AT_abstract_origin228 .byte 19 # DW_FORM_ref4229 .byte 17 # DW_AT_low_pc230 .byte 1 # DW_FORM_addr231 .byte 18 # DW_AT_high_pc232 .byte 6 # DW_FORM_data4233 .byte 88 # DW_AT_call_file234 .byte 11 # DW_FORM_data1235 .byte 89 # DW_AT_call_line236 .byte 11 # DW_FORM_data1237 .byte 87 # DW_AT_call_column238 .byte 11 # DW_FORM_data1239 .byte 0 # EOM(1)240 .byte 0 # EOM(2)241 .byte 10 # Abbreviation Code242 .byte 15 # DW_TAG_pointer_type243 .byte 0 # DW_CHILDREN_no244 .byte 73 # DW_AT_type245 .byte 19 # DW_FORM_ref4246 .byte 0 # EOM(1)247 .byte 0 # EOM(2)248 .byte 11 # Abbreviation Code249 .byte 38 # DW_TAG_const_type250 .byte 0 # DW_CHILDREN_no251 .byte 73 # DW_AT_type252 .byte 19 # DW_FORM_ref4253 .byte 0 # EOM(1)254 .byte 0 # EOM(2)255 .byte 0 # EOM(3)256 .section .debug_info,"",@progbits257.Lcu_begin0:258 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit259.Ldebug_info_start0:260 .short 4 # DWARF version number261 .long .debug_abbrev # Offset Into Abbrev. Section262 .byte 8 # Address Size (in bytes)263 .byte 1 # Abbrev [1] 0xb:0xc8 DW_TAG_compile_unit264 .long .Linfo_string0 # DW_AT_producer265 .short 33 # DW_AT_language266 .long .Linfo_string1 # DW_AT_name267 .long .Lline_table_start0 # DW_AT_stmt_list268 .long .Linfo_string2 # DW_AT_comp_dir269 .quad 0 # DW_AT_low_pc270 .long .Ldebug_ranges0 # DW_AT_ranges271 .byte 2 # Abbrev [2] 0x2a:0x1d DW_TAG_subprogram272 .quad .Lfunc_begin0 # DW_AT_low_pc273 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc274 .byte 1 # DW_AT_frame_base275 .byte 87276 # DW_AT_GNU_all_call_sites277 .long 71 # DW_AT_abstract_origin278 .byte 3 # Abbrev [3] 0x3d:0x9 DW_TAG_formal_parameter279 .long .Ldebug_loc0 # DW_AT_location280 .long 87 # DW_AT_abstract_origin281 .byte 0 # End Of Children Mark282 .byte 4 # Abbrev [4] 0x47:0x1c DW_TAG_subprogram283 .long .Linfo_string3 # DW_AT_linkage_name284 .long .Linfo_string4 # DW_AT_name285 .byte 1 # DW_AT_decl_file286 .byte 2 # DW_AT_decl_line287 .long 99 # DW_AT_type288 # DW_AT_external289 .byte 1 # DW_AT_inline290 .byte 5 # Abbrev [5] 0x57:0xb DW_TAG_formal_parameter291 .long .Linfo_string6 # DW_AT_name292 .byte 1 # DW_AT_decl_file293 .byte 2 # DW_AT_decl_line294 .long 99 # DW_AT_type295 .byte 0 # End Of Children Mark296 .byte 6 # Abbrev [6] 0x63:0x7 DW_TAG_base_type297 .long .Linfo_string5 # DW_AT_name298 .byte 5 # DW_AT_encoding299 .byte 4 # DW_AT_byte_size300 .byte 7 # Abbrev [7] 0x6a:0x52 DW_TAG_subprogram301 .quad .Lfunc_begin1 # DW_AT_low_pc302 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc303 .byte 1 # DW_AT_frame_base304 .byte 87305 # DW_AT_GNU_all_call_sites306 .long .Linfo_string7 # DW_AT_name307 .byte 1 # DW_AT_decl_file308 .byte 6 # DW_AT_decl_line309 .long 99 # DW_AT_type310 # DW_AT_external311 .byte 8 # Abbrev [8] 0x83:0xd DW_TAG_formal_parameter312 .byte 1 # DW_AT_location313 .byte 85314 .long .Linfo_string8 # DW_AT_name315 .byte 1 # DW_AT_decl_file316 .byte 6 # DW_AT_decl_line317 .long 99 # DW_AT_type318 .byte 8 # Abbrev [8] 0x90:0xd DW_TAG_formal_parameter319 .byte 1 # DW_AT_location320 .byte 84321 .long .Linfo_string9 # DW_AT_name322 .byte 1 # DW_AT_decl_file323 .byte 6 # DW_AT_decl_line324 .long 188 # DW_AT_type325 .byte 9 # Abbrev [9] 0x9d:0x1e DW_TAG_inlined_subroutine326 .long 71 # DW_AT_abstract_origin327 .quad .Lfunc_begin1 # DW_AT_low_pc328 .long .Ltmp2-.Lfunc_begin1 # DW_AT_high_pc329 .byte 1 # DW_AT_call_file330 .byte 7 # DW_AT_call_line331 .byte 10 # DW_AT_call_column332 .byte 3 # Abbrev [3] 0xb1:0x9 DW_TAG_formal_parameter333 .long .Ldebug_loc1 # DW_AT_location334 .long 87 # DW_AT_abstract_origin335 .byte 0 # End Of Children Mark336 .byte 0 # End Of Children Mark337 .byte 10 # Abbrev [10] 0xbc:0x5 DW_TAG_pointer_type338 .long 193 # DW_AT_type339 .byte 10 # Abbrev [10] 0xc1:0x5 DW_TAG_pointer_type340 .long 198 # DW_AT_type341 .byte 11 # Abbrev [11] 0xc6:0x5 DW_TAG_const_type342 .long 203 # DW_AT_type343 .byte 6 # Abbrev [6] 0xcb:0x7 DW_TAG_base_type344 .long .Linfo_string10 # DW_AT_name345 .byte 6 # DW_AT_encoding346 .byte 1 # DW_AT_byte_size347 .byte 0 # End Of Children Mark348.Ldebug_info_end0:349 .section .debug_ranges,"",@progbits350.Ldebug_ranges0:351 .quad .Lfunc_begin0352 .quad .Lfunc_end0353 .quad .Lfunc_begin1354 .quad .Lfunc_end1355 .quad 0356 .quad 0357 .section .debug_str,"MS",@progbits,1358.Linfo_string0:359 .asciz "clang version 15.0.0" # string offset=0360.Linfo_string1:361 .asciz "main.cpp" # string offset=134362.Linfo_string2:363 .asciz "." # string offset=143364.Linfo_string3:365 .asciz "_Z8doStuff2i" # string offset=181366.Linfo_string4:367 .asciz "doStuff2" # string offset=194368.Linfo_string5:369 .asciz "int" # string offset=203370.Linfo_string6:371 .asciz "val" # string offset=207372.Linfo_string7:373 .asciz "main" # string offset=211374.Linfo_string8:375 .asciz "argc" # string offset=216376.Linfo_string9:377 .asciz "argv" # string offset=221378.Linfo_string10:379 .asciz "char" # string offset=226380 .ident "clang version 15.0.0"381 .section ".note.GNU-stack","",@progbits382 .addrsig383 .section .debug_line,"",@progbits384.Lline_table_start0:385