1# REQUIRES: system-linux 2 3# RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %tmain.o --defsym MAIN=0 4# RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %thelper.o 5# RUN: %clang %cflags %tmain.o %thelper.o -o %tmain.exe 6# RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4 7# RUN: llvm-dwarfdump --debug-info %tmain.exe.bolt > %tout.text 8# RUN: llvm-dwarfdump --show-section-sizes %tmain.exe >> %tout.text 9# RUN: llvm-dwarfdump --show-section-sizes %tmain.exe.bolt >> %tout.text 10# RUN: cat %tout.text | FileCheck %s 11 12## This test checks that with DWARF5 when two CUs share the same .debug_str_offsets 13## entry BOLT does not create a duplicate. 14 15# CHECK: DW_AT_str_offsets_base (0x[[#%.8x,ADDR:]] 16# CHECK: DW_AT_str_offsets_base (0x[[#ADDR]] 17 18# CHECK: .debug_str_offsets [[#ADDR2:]] 19# CHECK: .debug_str_offsets [[#ADDR2]] 20 21# main.cpp 22# int main(){ 23# return 0; 24# } 25 26# helper.cpp 27# void foo(){} 28 29## Create two CUs, with dwo_ids 0 and 1 respectively. 30.ifdef MAIN 31.text 32 .file "main.cpp" 33 .globl main # -- Begin function main 34 .p2align 4, 0x90 35 .type main,@function 36main: # @main 37.Lfunc_begin0: 38 .file 0 "." "main.cpp" md5 0x32c197b0a8b855eb3d7573c993ada862 39 .loc 0 1 0 # main.cpp:1:0 40 .cfi_startproc 41# %bb.0: 42 pushq %rbp 43 .cfi_def_cfa_offset 16 44 .cfi_offset %rbp, -16 45 movq %rsp, %rbp 46 .cfi_def_cfa_register %rbp 47 movl $0, -4(%rbp) 48.Ltmp0: 49 .loc 0 2 1 prologue_end # main.cpp:2:1 50 xorl %eax, %eax 51 popq %rbp 52 .cfi_def_cfa %rsp, 8 53 retq 54.Ltmp1: 55.Lfunc_end0: 56 .size main, .Lfunc_end0-main 57 .cfi_endproc 58 # -- End function 59 .section .debug_abbrev,"",@progbits 60 .byte 1 # Abbreviation Code 61 .byte 17 # DW_TAG_compile_unit 62 .byte 1 # DW_CHILDREN_yes 63 .byte 37 # DW_AT_producer 64 .byte 37 # DW_FORM_strx1 65 .byte 19 # DW_AT_language 66 .byte 5 # DW_FORM_data2 67 .byte 3 # DW_AT_name 68 .byte 37 # DW_FORM_strx1 69 .byte 114 # DW_AT_str_offsets_base 70 .byte 23 # DW_FORM_sec_offset 71 .byte 16 # DW_AT_stmt_list 72 .byte 23 # DW_FORM_sec_offset 73 .byte 27 # DW_AT_comp_dir 74 .byte 37 # DW_FORM_strx1 75 .byte 17 # DW_AT_low_pc 76 .byte 27 # DW_FORM_addrx 77 .byte 18 # DW_AT_high_pc 78 .byte 6 # DW_FORM_data4 79 .byte 115 # DW_AT_addr_base 80 .byte 23 # DW_FORM_sec_offset 81 .byte 0 # EOM(1) 82 .byte 0 # EOM(2) 83 .byte 2 # Abbreviation Code 84 .byte 46 # DW_TAG_subprogram 85 .byte 0 # DW_CHILDREN_no 86 .byte 17 # DW_AT_low_pc 87 .byte 27 # DW_FORM_addrx 88 .byte 18 # DW_AT_high_pc 89 .byte 6 # DW_FORM_data4 90 .byte 64 # DW_AT_frame_base 91 .byte 24 # DW_FORM_exprloc 92 .byte 3 # DW_AT_name 93 .byte 37 # DW_FORM_strx1 94 .byte 58 # DW_AT_decl_file 95 .byte 11 # DW_FORM_data1 96 .byte 59 # DW_AT_decl_line 97 .byte 11 # DW_FORM_data1 98 .byte 73 # DW_AT_type 99 .byte 19 # DW_FORM_ref4 100 .byte 63 # DW_AT_external 101 .byte 25 # DW_FORM_flag_present 102 .byte 0 # EOM(1) 103 .byte 0 # EOM(2) 104 .byte 3 # Abbreviation Code 105 .byte 36 # DW_TAG_base_type 106 .byte 0 # DW_CHILDREN_no 107 .byte 3 # DW_AT_name 108 .byte 37 # DW_FORM_strx1 109 .byte 62 # DW_AT_encoding 110 .byte 11 # DW_FORM_data1 111 .byte 11 # DW_AT_byte_size 112 .byte 11 # DW_FORM_data1 113 .byte 0 # EOM(1) 114 .byte 0 # EOM(2) 115 .byte 0 # EOM(3) 116 .section .debug_info,"",@progbits 117.Lcu_begin0: 118 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 119.Ldebug_info_start0: 120 .short 5 # DWARF version number 121 .byte 1 # DWARF Unit Type 122 .byte 8 # Address Size (in bytes) 123 .long .debug_abbrev # Offset Into Abbrev. Section 124 .byte 1 # Abbrev [1] 0xc:0x2b DW_TAG_compile_unit 125 .byte 0 # DW_AT_producer 126 .short 33 # DW_AT_language 127 .byte 1 # DW_AT_name 128 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base 129 .long .Lline_table_start0 # DW_AT_stmt_list 130 .byte 2 # DW_AT_comp_dir 131 .byte 0 # DW_AT_low_pc 132 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 133 .long .Laddr_table_base0 # DW_AT_addr_base 134 .byte 2 # Abbrev [2] 0x23:0xf DW_TAG_subprogram 135 .byte 0 # DW_AT_low_pc 136 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 137 .byte 1 # DW_AT_frame_base 138 .byte 86 139 .byte 3 # DW_AT_name 140 .byte 0 # DW_AT_decl_file 141 .byte 1 # DW_AT_decl_line 142 .long 50 # DW_AT_type 143 # DW_AT_external 144 .byte 3 # Abbrev [3] 0x32:0x4 DW_TAG_base_type 145 .byte 4 # DW_AT_name 146 .byte 5 # DW_AT_encoding 147 .byte 4 # DW_AT_byte_size 148 .byte 0 # End Of Children Mark 149.Ldebug_info_end0: 150 .section .debug_str_offsets,"",@progbits 151 .long 24 # Length of String Offsets Set 152 .short 5 153 .short 0 154.Lstr_offsets_base0: 155 .section .debug_str,"MS",@progbits,1 156.Linfo_string0: 157 .asciz "clang version 15.0.0" # string offset=0 158.Linfo_string1: 159 .asciz "main.cpp" # string offset=146 160.Linfo_string2: 161 .asciz "." # string offset=155 162.Linfo_string3: 163 .asciz "main" # string offset=198 164.Linfo_string4: 165 .asciz "int" # string offset=203 166 .section .debug_str_offsets,"",@progbits 167 .long .Linfo_string0 168 .long .Linfo_string1 169 .long .Linfo_string2 170 .long .Linfo_string3 171 .long .Linfo_string4 172 .section .debug_addr,"",@progbits 173 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution 174.Ldebug_addr_start0: 175 .short 5 # DWARF version number 176 .byte 8 # Address size 177 .byte 0 # Segment selector size 178.Laddr_table_base0: 179 .quad .Lfunc_begin0 180.Ldebug_addr_end0: 181 .ident "clang version 15.0.0" 182 .section ".note.GNU-stack","",@progbits 183 .addrsig 184 .section .debug_line,"",@progbits 185.Lline_table_start0: 186.else 187.text 188 .file "helper.cpp" 189 .globl _Z3foov # -- Begin function _Z3foov 190 .p2align 4, 0x90 191 .type _Z3foov,@function 192_Z3foov: # @_Z3foov 193.Lfunc_begin0: 194 .file 0 "." "helper.cpp" md5 0x5f98e4807e4f8781c26a82faf819f8a7 195 .loc 0 1 0 # helper.cpp:1:0 196 .cfi_startproc 197# %bb.0: 198 pushq %rbp 199 .cfi_def_cfa_offset 16 200 .cfi_offset %rbp, -16 201 movq %rsp, %rbp 202 .cfi_def_cfa_register %rbp 203.Ltmp0: 204 .loc 0 1 12 prologue_end # helper.cpp:1:12 205 popq %rbp 206 .cfi_def_cfa %rsp, 8 207 retq 208.Ltmp1: 209.Lfunc_end0: 210 .size _Z3foov, .Lfunc_end0-_Z3foov 211 .cfi_endproc 212 # -- End function 213 .section .debug_abbrev,"",@progbits 214 .byte 1 # Abbreviation Code 215 .byte 17 # DW_TAG_compile_unit 216 .byte 1 # DW_CHILDREN_yes 217 .byte 37 # DW_AT_producer 218 .byte 37 # DW_FORM_strx1 219 .byte 19 # DW_AT_language 220 .byte 5 # DW_FORM_data2 221 .byte 3 # DW_AT_name 222 .byte 37 # DW_FORM_strx1 223 .byte 114 # DW_AT_str_offsets_base 224 .byte 23 # DW_FORM_sec_offset 225 .byte 16 # DW_AT_stmt_list 226 .byte 23 # DW_FORM_sec_offset 227 .byte 27 # DW_AT_comp_dir 228 .byte 37 # DW_FORM_strx1 229 .byte 17 # DW_AT_low_pc 230 .byte 27 # DW_FORM_addrx 231 .byte 18 # DW_AT_high_pc 232 .byte 6 # DW_FORM_data4 233 .byte 115 # DW_AT_addr_base 234 .byte 23 # DW_FORM_sec_offset 235 .byte 0 # EOM(1) 236 .byte 0 # EOM(2) 237 .byte 2 # Abbreviation Code 238 .byte 46 # DW_TAG_subprogram 239 .byte 0 # DW_CHILDREN_no 240 .byte 17 # DW_AT_low_pc 241 .byte 27 # DW_FORM_addrx 242 .byte 18 # DW_AT_high_pc 243 .byte 6 # DW_FORM_data4 244 .byte 64 # DW_AT_frame_base 245 .byte 24 # DW_FORM_exprloc 246 .byte 110 # DW_AT_linkage_name 247 .byte 37 # DW_FORM_strx1 248 .byte 3 # DW_AT_name 249 .byte 37 # DW_FORM_strx1 250 .byte 58 # DW_AT_decl_file 251 .byte 11 # DW_FORM_data1 252 .byte 59 # DW_AT_decl_line 253 .byte 11 # DW_FORM_data1 254 .byte 63 # DW_AT_external 255 .byte 25 # DW_FORM_flag_present 256 .byte 0 # EOM(1) 257 .byte 0 # EOM(2) 258 .byte 0 # EOM(3) 259 .section .debug_info,"",@progbits 260.Lcu_begin0: 261 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 262.Ldebug_info_start0: 263 .short 5 # DWARF version number 264 .byte 1 # DWARF Unit Type 265 .byte 8 # Address Size (in bytes) 266 .long .debug_abbrev # Offset Into Abbrev. Section 267 .byte 1 # Abbrev [1] 0xc:0x24 DW_TAG_compile_unit 268 .byte 0 # DW_AT_producer 269 .short 33 # DW_AT_language 270 .byte 1 # DW_AT_name 271 .long 0x8 # DW_AT_str_offsets_base Manually modified to be the same as first CU 272 .long .Lline_table_start0 # DW_AT_stmt_list 273 .byte 2 # DW_AT_comp_dir 274 .byte 0 # DW_AT_low_pc 275 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 276 .long .Laddr_table_base0 # DW_AT_addr_base 277 .byte 2 # Abbrev [2] 0x23:0xc DW_TAG_subprogram 278 .byte 0 # DW_AT_low_pc 279 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 280 .byte 1 # DW_AT_frame_base 281 .byte 86 282 .byte 3 # DW_AT_linkage_name 283 .byte 4 # DW_AT_name 284 .byte 0 # DW_AT_decl_file 285 .byte 1 # DW_AT_decl_line 286 # DW_AT_external 287 .byte 0 # End Of Children Mark 288.Ldebug_info_end0: 289# Manually removed .debug_str_offsets and .debug_str 290 .section .debug_addr,"",@progbits 291 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution 292.Ldebug_addr_start0: 293 .short 5 # DWARF version number 294 .byte 8 # Address size 295 .byte 0 # Segment selector size 296.Laddr_table_base0: 297 .quad .Lfunc_begin0 298.Ldebug_addr_end0: 299 .ident "clang version 15.0.0" 300 .section ".note.GNU-stack","",@progbits 301 .addrsig 302 .section .debug_line,"",@progbits 303.Lline_table_start0: 304.endif 305