This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use comdat sections to reduce the size of debug info


I've proposed an extension to the DWARF-4 format to support the
ability to place individual type definitions in separate comdat
.debug_types sections. See the wiki page on the DWARF website for
background and details:

  http://wiki.dwarfstd.org/index.php?title=COMDAT_Type_Sections

The attached patch implements this proposal in gcc, using the
-gdwarf-4 flag to enable the use of (for now, experimental) DWARF-4
features. The compiler places fully-defined struct, class, union, and
enum types in separate comdat sections, provides a hashed type
signature for each as the comdat key, and lets the linker to its
regular job of duplicate comdat elimination. In my testing, I've found
that it can reduce the size of the debug info (type DIEs + non-type
DIES + strings) by about 40%, and I suspect that it can be improved.

This may sound familiar, as it's somewhat related to the existing
-feliminate-dwarf2-dups option. The DWARF wiki page discusses how this
approach improves on the older one.

I've got a binutils patch ready to add support for the new
.debug_types section to readelf and objdump as well. We're still
working on adding the gdb support.

The compiler bootstraps and test results are the same pre- and
post-patch for C and C++. There is no change in compiler behavior
without the -gdwarf-4 flag. I'll gladly take any hints and guidance
for adding new tests for this option.

-cary


2008-08-15  Cary Coutant  <ccoutant@google.com>

	Add support for comdat type sections for DWARF v4.
	* flags.h (use_dwarf4_extensions): New flag.
	* dwarf2out.c (DWARF_TYPE_FULL_SIGNATURE_SIZE): New constant.
	(DWARF_TYPE_SIGNATURE_SIZE): New constant.
	(DW_FORM_sig): New constant.
	(dw_die_ref): Define vector type.
	(comdat_type_node_ref): New type.
	(struct die_struct): Move die_symbol into a union; add new field
	die_type_node.  Change all uses.
	(comdat_type_node): New type.
	(skeleton_chain_node): New type.
	(DWARF_COMDAT_TYPE_UNIT_HEADER_SIZE): New constant.
	(comdat_type_list): New variable.
	(replace_child): New function.
	(move_all_children): New function.
	(print_die): Print signature information.
	(attr_checksum_ordered): New function.
	(die_checksum_ordered): New function.
	(checksum_die_context): New function.
	(generate_type_signature): New function.
	(is_specification): New function.
	(should_move_die_to_comdat): New function.
	(clone_as_specification): New function.
	(clone_die): New function.
	(clone_tree): New function.
	(copy_ancestor_tree): New function.
	(copy_declaration_context): New function.
	(generate_skeleton_ancestor_tree): New function.
	(generate_skeleton_bottom_up): New function.
	(generate_skeleton): New function.
	(remove_child_or_replace_with_skeleton): New function.
	(break_out_comdat_types): New function.
	(struct decl_table_entry): New type.
	(htab_decl_hash): New function.
	(htab_decl_eq): New function.
	(htab_decl_del): New function.
	(copy_decls_walk): New function.
	(copy_decls_for_unworthy_types): New function.
	(unmark_dies): Don't assert for unmarked dies when doing comdat
	type sections.
	(value_format): Support DW_FORM_sig4 and DW_FORM_sig8.
	(output_die): Likewise.
	(output_comdat_type_unit): New function.
	(dwarf2out_start_source_file): Don't do eliminate_dwarf2_dups with
	DWARF-4.
	(prune_unused_types_walk_attribs): Don't follow references into
	comdat type sections.
	(prune_unused_types): Process comdat type sections.
	(htab_ct_hash): New function.
	(htab_ct_eq): New function.
	(dwarf2out_finish): Move types to comdat sections when using DWARF-4.
	* opts.c (use_dwarf4_extensions): New flag.
	(common_handle_option): Add support for -gdwarf-4 option.
	* dwarf2.h (enum dwarf_form): Add new DWARF-4 FORMs.
	* common.opt: Add -gdwarf-4 option.
	* varasm.c (default_elf_asm_named_section): Use identifier name as
	comdat key instead of lang hook.

Attachment: comdat-types-patch-f.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]