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 Darwin] Fix PRs 33120, 35710, 26427


Hi,

This patch, based in part on Mike's comment #10 in PR33120, is a re- write of Darwin's zeroed-storage allocators.

* It addresses PR 33120 by making use of (aligned) .zerofill sections where possible.
* it addresses the section anchors problem(s) by moving zero-sized objects into distinct sections which are not allowed to participate in section anchoring.


FWIW: The problems previously seen with pr33120/c#10 and libjava were, in the main, a result of fails in boehm-gc which needs to know _all_ writable data sections.

* On i686-darwin9 I see around a 4% reduction in the sum of the sizes of all objects in gcc/ (gcc-stage2 --- stage3 changes are swamped by the debug)
* cc1* are around 6% smaller on disk.


regstrapped [incl. Java] on i686-darwin{8,9} x86_64-darwin10
regstrapped [incl. Java] with:
make BOOT_CFLAGS="-g -O2 -fsection-anchors" CFLAGS_FOR_TARGET="-g - O2 -fsection-anchors"
on powerpc-darwin9 (and without the -fsection-anchors too).


regtested with -fsection-anchors on powerpc-darwin9 (no unexpected fails)
- in particular, compat.exp and struct-layout-1.exp pass with no regressions (these include zero-sized objects).


- not tested (yet) on powerpc-darwin8 - but I figure that the worst- case would be to override the macros back to the pre-existing version for ppc-d8 if there was a show-stopper.

All changes (including the boehm-gc ones) are Darwin-local --

--- but it would be useful if we could decide on :
http://gcc.gnu.org/ml/gcc-patches/2010-11/msg01469.html (unreviewed) since this would allow us to remove the duplicated checks for weak and decl_one stuff in each allocator .... that's why copied to Richard.


OK for trunk?
Iain

P.S. I noticed while doing this that boehm-gc test results don't seem to make it to the output - and that boehm-gc make check is not run for the multilib (unless one does it by hand) - I assume that this is intentional?

===

all changes prefixed by

	Iain Sandoe <..>
	Mike Stump <...>

	PR target/26427
	PR target/33120
	PR testsuite/35710

gcc:

* config/i386/darwin.h (ASM_OUTPUT_COMMON): Remove
(ASM_OUTPUT_LOCAL): Likewise.
* config/darwin-protos.h (darwin_asm_declare_object_name): New Prototype.
(darwin_output_aligned_bss): Likewise.
(darwin_asm_output_aligned_decl_local): Likewise.
(darwin_asm_output_aligned_decl_common): Likewise.
(darwin_use_anchors_for_symbol_p): Likewise.
* config/rs6000/darwin.h (ASM_OUTPUT_COMMON): Remove.
(TARGET_ASM_OUTPUT_ANCHOR): Define.
(TARGET_USE_ANCHORS_FOR_SYMBOL_P): Define.
(DARWIN_SECTION_ANCHORS): Set to 1.
* config/darwin.c (emit_aligned_common): New var.
(darwin_init_sections): Check that the Darwin private zero-size section marker is in range.
(darwin_text_section): Check for zero-sized objects.
(darwin_mergeable_string_section): Likewise.
(darwin_mergeable_constant_section): Likewise.
(machopic_select_section): Adjust to check for zero-sized objects. Assert that OBJC meta data are non-zero sized.
(darwin_asm_declare_object_name): New.
(darwin_asm_declare_constant_name): Adjust for zero-sized object sections.
(BYTES_ZFILL): Define.
(darwin_emit_weak_or_comdat): New.
(darwin_emit_local_bss): New.
(darwin_emit_common): New.
(darwin_output_aligned_bss): New.
(darwin_asm_output_aligned_decl_common): New.
(darwin_asm_output_aligned_decl_local): New.
(darwin_file_end): Disable subsections_via_symbols when section anchoring is active.
(darwin_asm_output_anchor): Re-enable.
(darwin_use_anchors_for_symbol_p): New.
(darwin_override_options): Check for versions that can emit aligned common. Update usage of flags to current.
* config/darwin-sections.def: Update comments and flags for non- anchor sections.
zobj_const_section, zobj_data_section, zobj_bss_section, zobj_const_data_section: New.
* config/darwin.h (ASM_DECLARE_OBJECT_NAME): Redefine.
(ASM_OUTPUT_ALIGN): Make whitespace output consistent.
(L2_MAX_OFILE_ALIGNMENT): Define.
(ASM_OUTPUT_ALIGNED_BSS): Define.
(ASM_OUTPUT_ALIGNED_DECL_LOCAL): Define.
(ASM_OUTPUT_ALIGNED_DECL_COMMON): Define.
(SECTION_NO_ANCHOR): Define.
(TARGET_ASM_OUTPUT_ANCHOR) Define with a default of NULL.
(DARWIN_SECTION_ANCHORS): Define with a default of 0.


boehm-gc:

* dyn_load.c (GC_register_dynamic_libraries/DARWIN): Add new writable data section names.
(GC_dyld_name_for_hdr): Adjust layout.
(GC_dyld_image_add): Adjust layout, add new Darwin sections, adjust debug to name the sections.
(GC_dyld_image_remove): Adjust layout, remove new Darwin sections, adjust debug to name the sections.
(GC_register_dynamic_libraries): Adjust layout.
(GC_init_dyld): Likewise.
(GC_register_main_static_data): Likewise.


gcc/testsuite:

	* gcc.target/powerpc/darwin-abi-12.c: Adjust for new allocators.
	* gcc.dg/pr26427.c: Remove redundant warning.
	* gcc.dg/darwin-comm.c: Adjust for new allocators.
	* gcc.dg/darwin-sections.c: New test.
	* g++.dg/ext/instantiate2.C: Adjust for new allocators.


Attachment: 167184-darwin-mem-patch.txt
Description: Text document









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