From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id DB8683857C52; Sat, 10 Oct 2020 15:50:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB8683857C52 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-3765] Darwin : Begin rework of zero-fill sections. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/master X-Git-Oldrev: 16664e6e4fb4281be6477c13989740d44c963c77 X-Git-Newrev: dcf59c5c0100d0649d64ec948dbe24018d48b6a5 Message-Id: <20201010155008.DB8683857C52@sourceware.org> Date: Sat, 10 Oct 2020 15:50:08 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Oct 2020 15:50:09 -0000 https://gcc.gnu.org/g:dcf59c5c0100d0649d64ec948dbe24018d48b6a5 commit r11-3765-gdcf59c5c0100d0649d64ec948dbe24018d48b6a5 Author: Iain Sandoe Date: Sat Aug 22 17:40:20 2020 +0100 Darwin : Begin rework of zero-fill sections. Much of the existing work in the Darwin BSS and common sections was to accommodate the PowerPC section anchors. We want to segregate this, since it might become desirable to support section anchors for arm64. First revision (here) is to use the same section conventions as the Xcode toochains for BSS and COMMON. We also drop the constraint about putting small items into data/static data that was a work-around for Java issues (irrelevant for several editions). gcc/ChangeLog: * config/darwin.c (darwin_emit_local_bss): Amend section names to match system tools. (darwin_output_aligned_bss): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/darwin-sections.c: Adjust test for renamed BSS and common sections. Cater for 64 and 128 bit long doubles. Diff: --- gcc/config/darwin.c | 42 ++++++++++++---------------------- gcc/testsuite/gcc.dg/darwin-sections.c | 42 +++++++++++++++------------------- 2 files changed, 33 insertions(+), 51 deletions(-) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index b64aaa7b1a7..23116484724 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -2384,11 +2384,7 @@ darwin_emit_local_bss (FILE *fp, tree decl, const char *name, unsigned HOST_WIDE_INT size, unsigned int l2align) { - /* FIXME: We have a fudge to make this work with Java even when the target does - not use sections anchors -- Java seems to need at least one small item in a - non-zerofill segment. */ - if ((DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL) - || (size && size <= 2)) + if (DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL) { /* Put smaller objects in _static_data, where the section anchors system can get them. @@ -2414,16 +2410,13 @@ darwin_emit_local_bss (FILE *fp, tree decl, const char *name, } else { - /* When we are on a non-section anchor target, we can get zero-sized - items here. However, all we need to do is to bump them to one byte - and the section alignment will take care of the rest. */ + /* When we are on a non-section anchor target (or not using section + anchors, we can get zero-sized items here. However, all we need to + do is to bump them to one byte and the section alignment will take + care of the rest. */ char secnam[64]; - unsigned int flags ; - snprintf (secnam, 64, "__DATA,__%sbss%u", ((size)?"":"zo_"), - (unsigned) l2align); - /* We can't anchor (yet, if ever) in zerofill sections, because we can't - switch to them and emit a label. */ - flags = SECTION_BSS|SECTION_WRITE|SECTION_NO_ANCHOR; + snprintf (secnam, 64, "__DATA,__bss"); + unsigned int flags = SECTION_BSS|SECTION_WRITE|SECTION_NO_ANCHOR; in_section = get_section (secnam, flags, NULL); fprintf (fp, "\t.zerofill %s,", secnam); assemble_name (fp, name); @@ -2434,7 +2427,7 @@ darwin_emit_local_bss (FILE *fp, tree decl, const char *name, fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", size, (unsigned) l2align); else - fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED"\n", size); + fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED",0\n", size); } (*targetm.encode_section_info) (decl, DECL_RTL (decl), false); @@ -2559,9 +2552,8 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d stat %d com %d" return; } - /* So we have a public symbol (small item fudge for Java, see above). */ - if ((DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL) - || (size && size <= 2)) + /* So we have a public symbol. */ + if (DARWIN_SECTION_ANCHORS && flag_section_anchors && size < BYTES_ZFILL) { /* Put smaller objects in data, where the section anchors system can get them. However, if they are zero-sized punt them to yet a different @@ -2586,16 +2578,10 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d stat %d com %d" } else { + /* Section anchors not in use. */ + unsigned int flags = SECTION_BSS|SECTION_WRITE|SECTION_NO_ANCHOR; char secnam[64]; - unsigned int flags ; - /* When we are on a non-section anchor target, we can get zero-sized - items here. However, all we need to do is to bump them to one byte - and the section alignment will take care of the rest. */ - snprintf (secnam, 64, "__DATA,__%spu_bss%u", ((size)?"":"zo_"), l2align); - - /* We can't anchor in zerofill sections, because we can't switch - to them and emit a label. */ - flags = SECTION_BSS|SECTION_WRITE|SECTION_NO_ANCHOR; + snprintf (secnam, 64, "__DATA,__common"); in_section = get_section (secnam, flags, NULL); fprintf (fp, "\t.zerofill %s,", secnam); assemble_name (fp, name); @@ -2605,7 +2591,7 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d stat %d com %d" if (l2align) fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", size, l2align); else - fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED"\n", size); + fprintf (fp, "," HOST_WIDE_INT_PRINT_UNSIGNED",0\n", size); } (* targetm.encode_section_info) (decl, DECL_RTL (decl), false); } diff --git a/gcc/testsuite/gcc.dg/darwin-sections.c b/gcc/testsuite/gcc.dg/darwin-sections.c index 276ffa391ed..dbe37027f89 100644 --- a/gcc/testsuite/gcc.dg/darwin-sections.c +++ b/gcc/testsuite/gcc.dg/darwin-sections.c @@ -13,45 +13,41 @@ e_s ea; /* { dg-final { scan-assembler ".comm\[\t \]_ub,1" } } */ /* { dg-final { scan-assembler ".comm\[\t \]_ea,1" } } */ -/* These should go into .data */ +/* These should go into __DATA,__common */ char a = 0; short b = 0; -/* { dg-final { scan-assembler ".globl _a.*.data.*.space\[\t \]1" } } */ -/* { dg-final { scan-assembler ".globl _b.*.data.*.space\[\t \]2" } } */ - -/* These should go into __pu_bssN */ long long d = 0; float e = 0; double f = 0; long double g = 0.L; long long al_256 __attribute__((aligned (256))) = 0; -/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss3,_d,8,3" } } */ -/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss2,_e,4,2" } } */ -/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss3,_f,8,3" } } */ -/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss4,_g,16,4" } } */ -/* { dg-final { scan-assembler ".zerofill __DATA,__pu_bss8,_al_256,8,8" } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_a,1,0} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_b,2,1} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_d,8,3} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_e,4,2} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_f,8,3} } } */ +/* long double can be 64 or 128 bits depending on the Darwin subtarget. */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_g,(16,4|8,3)} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__common,_al_256,8,8} } } */ -/* This should go into __zo_bss0 */ +/* These should go into __DATA,__bss */ static e_s sea; -/* { dg-final { scan-assembler ".zerofill __DATA,__zo_bss0,_sea,1" } } */ - -/* These should go into .static_data */ static char sa ; static short sb ; -/* { dg-final { scan-assembler ".static_data.*_sa:.*.space\[\t \]1" } } */ -/* { dg-final { scan-assembler ".static_data.*_sb:.*.space\[\t \]2" } } */ - -/* These should go into _bssN */ static long long sd; static float se ; static double sf ; static long double sg; static long long sal_256 __attribute__((aligned (2048))); -/* { dg-final { scan-assembler ".zerofill __DATA,__bss3,_sd,8,3" } } */ -/* { dg-final { scan-assembler ".zerofill __DATA,__bss2,_se,4,2" } } */ -/* { dg-final { scan-assembler ".zerofill __DATA,__bss3,_sf,8,3" } } */ -/* { dg-final { scan-assembler ".zerofill __DATA,__bss4,_sg,16,4" } } */ -/* { dg-final { scan-assembler ".zerofill __DATA,__bss11,_sal_256,8,11" } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sea,1,0} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sa,1,0} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sb,2,1} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sd,8,3} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_se,4,2} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sf,8,3} } } */ +/* long double can be 64 or 128 bits depending on the Darwin subtarget. */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sg,(16,4|8,3)} } } */ +/* { dg-final { scan-assembler {.zerofill __DATA,__bss,_sal_256,8,11} } } */ long long foo (int x) {