Skip to content

[BOLT][DWARF] Do not emit zero low_pc address arange #81955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,9 @@ void DWARFRewriter::updateUnitDebugInfo(
OutputRanges.push_back({0, 0});
const uint64_t RangesSectionOffset =
RangesSectionWriter.addRanges(OutputRanges);
if (!Unit.isDWOUnit())
// Don't emit the zero low_pc arange.
if (!Unit.isDWOUnit() && !OutputRanges.empty() &&
OutputRanges.back().LowPC)
ARangesSectionWriter->addCURanges(Unit.getOffset(),
std::move(OutputRanges));
updateDWARFObjectAddressRanges(Unit, DIEBldr, *Die, RangesSectionOffset,
Expand Down
325 changes: 325 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-empty-arange-helper.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
# clang++ -O0 -g2 -S -ffunction-sections -o
# int Foo;
# int helper() {
# return 0;
# }
#
# int helperhelper() {
# return 0;
# }
# int helperhelper2() {
# return 1;
# }

.text
.file "helper.cpp"
.file 0 "/repro2" "helper.cpp" md5 0xef451fc8d099ed067c9f2ff97d8aacf6
.section .text._Z6helperv,"ax",@progbits
.globl _Z6helperv # -- Begin function _Z6helperv
.p2align 4, 0x90
.type _Z6helperv,@function
_Z6helperv: # @_Z6helperv
.Lfunc_begin0:
.loc 0 2 0 # helper.cpp:2:0
.cfi_startproc
# %bb.0: # %entry
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
.Ltmp0:
.loc 0 3 3 prologue_end # helper.cpp:3:3
xorl %eax, %eax
.loc 0 3 3 epilogue_begin is_stmt 0 # helper.cpp:3:3
popq %rbp
.cfi_def_cfa %rsp, 8
retq
.Ltmp1:
.Lfunc_end0:
.size _Z6helperv, .Lfunc_end0-_Z6helperv
.cfi_endproc
# -- End function
.section .text._Z12helperhelperv,"ax",@progbits
.globl _Z12helperhelperv # -- Begin function _Z12helperhelperv
.p2align 4, 0x90
.type _Z12helperhelperv,@function
_Z12helperhelperv: # @_Z12helperhelperv
.Lfunc_begin1:
.loc 0 5 0 is_stmt 1 # helper.cpp:5:0
.cfi_startproc
# %bb.0: # %entry
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
.Ltmp2:
.loc 0 6 3 prologue_end # helper.cpp:6:3
xorl %eax, %eax
.loc 0 6 3 epilogue_begin is_stmt 0 # helper.cpp:6:3
popq %rbp
.cfi_def_cfa %rsp, 8
retq
.Ltmp3:
.Lfunc_end1:
.size _Z12helperhelperv, .Lfunc_end1-_Z12helperhelperv
.cfi_endproc
# -- End function
.section .text._Z13helperhelper2v,"ax",@progbits
.globl _Z13helperhelper2v # -- Begin function _Z13helperhelper2v
.p2align 4, 0x90
.type _Z13helperhelper2v,@function
_Z13helperhelper2v: # @_Z13helperhelper2v
.Lfunc_begin2:
.loc 0 8 0 is_stmt 1 # helper.cpp:8:0
.cfi_startproc
# %bb.0: # %entry
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
.Ltmp4:
.loc 0 9 3 prologue_end # helper.cpp:9:3
movl $1, %eax
.loc 0 9 3 epilogue_begin is_stmt 0 # helper.cpp:9:3
popq %rbp
.cfi_def_cfa %rsp, 8
retq
.Ltmp5:
.Lfunc_end2:
.size _Z13helperhelper2v, .Lfunc_end2-_Z13helperhelper2v
.cfi_endproc
# -- End function
.type Foo,@object # @Foo
.bss
.globl Foo
.p2align 2, 0x0
Foo:
.long 0 # 0x0
.size Foo, 4

.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code
.byte 17 # DW_TAG_compile_unit
.byte 1 # DW_CHILDREN_yes
.byte 37 # DW_AT_producer
.byte 37 # DW_FORM_strx1
.byte 19 # DW_AT_language
.byte 5 # DW_FORM_data2
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 114 # DW_AT_str_offsets_base
.byte 23 # DW_FORM_sec_offset
.byte 16 # DW_AT_stmt_list
.byte 23 # DW_FORM_sec_offset
.byte 27 # DW_AT_comp_dir
.byte 37 # DW_FORM_strx1
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 85 # DW_AT_ranges
.byte 35 # DW_FORM_rnglistx
.byte 115 # DW_AT_addr_base
.byte 23 # DW_FORM_sec_offset
.byte 116 # DW_AT_rnglists_base
.byte 23 # DW_FORM_sec_offset
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 2 # Abbreviation Code
.byte 52 # DW_TAG_variable
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 63 # DW_AT_external
.byte 25 # DW_FORM_flag_present
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 2 # DW_AT_location
.byte 24 # DW_FORM_exprloc
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 3 # Abbreviation Code
.byte 36 # DW_TAG_base_type
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 62 # DW_AT_encoding
.byte 11 # DW_FORM_data1
.byte 11 # DW_AT_byte_size
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 4 # Abbreviation Code
.byte 46 # DW_TAG_subprogram
.byte 0 # DW_CHILDREN_no
.byte 17 # DW_AT_low_pc
.byte 27 # DW_FORM_addrx
.byte 18 # DW_AT_high_pc
.byte 6 # DW_FORM_data4
.byte 64 # DW_AT_frame_base
.byte 24 # DW_FORM_exprloc
.byte 110 # DW_AT_linkage_name
.byte 37 # DW_FORM_strx1
.byte 3 # DW_AT_name
.byte 37 # DW_FORM_strx1
.byte 58 # DW_AT_decl_file
.byte 11 # DW_FORM_data1
.byte 59 # DW_AT_decl_line
.byte 11 # DW_FORM_data1
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 63 # DW_AT_external
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 0 # EOM(3)
.section .debug_info,"",@progbits
.Lcu_begin0:
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
.Ldebug_info_start0:
.short 5 # DWARF version number
.byte 1 # DWARF Unit Type
.byte 8 # Address Size (in bytes)
.long .debug_abbrev # Offset Into Abbrev. Section
.byte 1 # Abbrev [1] 0xc:0x5f DW_TAG_compile_unit
.byte 0 # DW_AT_producer
.short 33 # DW_AT_language
.byte 1 # DW_AT_name
.long .Lstr_offsets_base0 # DW_AT_str_offsets_base
.long .Lline_table_start0 # DW_AT_stmt_list
.byte 2 # DW_AT_comp_dir
.quad 0 # DW_AT_low_pc
.byte 0 # DW_AT_ranges
.long .Laddr_table_base0 # DW_AT_addr_base
.long .Lrnglists_table_base0 # DW_AT_rnglists_base
.byte 2 # Abbrev [2] 0x2b:0xb DW_TAG_variable
.byte 3 # DW_AT_name
.long 54 # DW_AT_type
# DW_AT_external
.byte 0 # DW_AT_decl_file
.byte 1 # DW_AT_decl_line
.byte 2 # DW_AT_location
.byte 161
.byte 0
.byte 3 # Abbrev [3] 0x36:0x4 DW_TAG_base_type
.byte 4 # DW_AT_name
.byte 5 # DW_AT_encoding
.byte 4 # DW_AT_byte_size
.byte 4 # Abbrev [4] 0x3a:0x10 DW_TAG_subprogram
.byte 1 # DW_AT_low_pc
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
.byte 1 # DW_AT_frame_base
.byte 86
.byte 5 # DW_AT_linkage_name
.byte 6 # DW_AT_name
.byte 0 # DW_AT_decl_file
.byte 2 # DW_AT_decl_line
.long 54 # DW_AT_type
# DW_AT_external
.byte 4 # Abbrev [4] 0x4a:0x10 DW_TAG_subprogram
.byte 2 # DW_AT_low_pc
.long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
.byte 1 # DW_AT_frame_base
.byte 86
.byte 7 # DW_AT_linkage_name
.byte 8 # DW_AT_name
.byte 0 # DW_AT_decl_file
.byte 5 # DW_AT_decl_line
.long 54 # DW_AT_type
# DW_AT_external
.byte 4 # Abbrev [4] 0x5a:0x10 DW_TAG_subprogram
.byte 3 # DW_AT_low_pc
.long .Lfunc_end2-.Lfunc_begin2 # DW_AT_high_pc
.byte 1 # DW_AT_frame_base
.byte 86
.byte 9 # DW_AT_linkage_name
.byte 10 # DW_AT_name
.byte 0 # DW_AT_decl_file
.byte 8 # DW_AT_decl_line
.long 54 # DW_AT_type
# DW_AT_external
.byte 0 # End Of Children Mark
.Ldebug_info_end0:
.section .debug_rnglists,"",@progbits
.long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
.Ldebug_list_header_start0:
.short 5 # Version
.byte 8 # Address size
.byte 0 # Segment selector size
.long 1 # Offset entry count
.Lrnglists_table_base0:
.long .Ldebug_ranges0-.Lrnglists_table_base0
.Ldebug_ranges0:
.byte 3 # DW_RLE_startx_length
.byte 1 # start index
.uleb128 .Lfunc_end0-.Lfunc_begin0 # length
.byte 3 # DW_RLE_startx_length
.byte 2 # start index
.uleb128 .Lfunc_end1-.Lfunc_begin1 # length
.byte 3 # DW_RLE_startx_length
.byte 3 # start index
.uleb128 .Lfunc_end2-.Lfunc_begin2 # length
.byte 0 # DW_RLE_end_of_list
.Ldebug_list_header_end0:
.section .debug_str_offsets,"",@progbits
.long 48 # Length of String Offsets Set
.short 5
.short 0
.Lstr_offsets_base0:
.section .debug_str,"MS",@progbits,1
.Linfo_string0:
.asciz "clang version 19.0.0git ([email protected]:ayermolo/llvm-project.git 6c884ef47e88e5ff18353819e806fe1b84e3c5b5)" # string offset=0
.Linfo_string1:
.asciz "helper.cpp" # string offset=108
.Linfo_string2:
.asciz "/repro2" # string offset=119
.Linfo_string3:
.asciz "Foo" # string offset=164
.Linfo_string4:
.asciz "int" # string offset=168
.Linfo_string5:
.asciz "_Z6helperv" # string offset=172
.Linfo_string6:
.asciz "helper" # string offset=183
.Linfo_string7:
.asciz "_Z12helperhelperv" # string offset=190
.Linfo_string8:
.asciz "helperhelper" # string offset=208
.Linfo_string9:
.asciz "_Z13helperhelper2v" # string offset=221
.Linfo_string10:
.asciz "helperhelper2" # string offset=240
.section .debug_str_offsets,"",@progbits
.long .Linfo_string0
.long .Linfo_string1
.long .Linfo_string2
.long .Linfo_string3
.long .Linfo_string4
.long .Linfo_string5
.long .Linfo_string6
.long .Linfo_string7
.long .Linfo_string8
.long .Linfo_string9
.long .Linfo_string10
.section .debug_addr,"",@progbits
.long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
.Ldebug_addr_start0:
.short 5 # DWARF version number
.byte 8 # Address size
.byte 0 # Segment selector size
.Laddr_table_base0:
.quad Foo
.quad .Lfunc_begin0
.quad .Lfunc_begin1
.quad .Lfunc_begin2
.Ldebug_addr_end0:
.ident "clang version 19.0.0git ([email protected]:ayermolo/llvm-project.git 6c884ef47e88e5ff18353819e806fe1b84e3c5b5)"
.section ".note.GNU-stack","",@progbits
.addrsig
.section .debug_line,"",@progbits
.Lline_table_start0:
Loading