From e645202012d9c0d55f46c5c818a64e65a1b9c89c Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Thu, 7 Nov 2024 00:57:26 +0300 Subject: [PATCH] Do not GC function declarations Declarations must be consistent across compilation units. --- crates/cranelift/src/debug/gc.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/cranelift/src/debug/gc.rs b/crates/cranelift/src/debug/gc.rs index bb45e8e838a7..10849419ca8c 100644 --- a/crates/cranelift/src/debug/gc.rs +++ b/crates/cranelift/src/debug/gc.rs @@ -108,8 +108,8 @@ fn build_unit_dependencies( Ok(()) } -fn has_die_back_edge(die: &read::DebuggingInformationEntry>) -> bool { - match die.tag() { +fn has_die_back_edge(die: &read::DebuggingInformationEntry>) -> read::Result { + let result = match die.tag() { constants::DW_TAG_variable | constants::DW_TAG_constant | constants::DW_TAG_inlined_subroutine @@ -124,8 +124,10 @@ fn has_die_back_edge(die: &read::DebuggingInformationEntry>) -> bool | constants::DW_TAG_variant_part | constants::DW_TAG_variant | constants::DW_TAG_formal_parameter => true, + constants::DW_TAG_subprogram => die.attr(constants::DW_AT_declaration)?.is_some(), _ => false, - } + }; + Ok(result) } fn has_valid_code_range( @@ -223,7 +225,7 @@ fn build_die_dependencies( let child_entry = child.entry(); let child_offset = child_entry.offset().to_unit_section_offset(unit); deps.add_edge(child_offset, offset); - if has_die_back_edge(child_entry) { + if has_die_back_edge(child_entry)? { deps.add_edge(offset, child_offset); } if has_valid_code_range(child_entry, dwarf, unit, at)? {