From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93730 invoked by alias); 27 Nov 2017 08:22:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 93574 invoked by uid 89); 27 Nov 2017 08:22:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Nov 2017 08:22:23 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1725AAAD0; Mon, 27 Nov 2017 08:22:21 +0000 (UTC) Date: Mon, 27 Nov 2017 08:38:00 -0000 From: Richard Biener To: Jakub Jelinek cc: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix bss_initializer_p (PR target/83100) In-Reply-To: <20171124231352.GF14653@tucnak> Message-ID: References: <20171124231352.GF14653@tucnak> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2017-11/txt/msg02260.txt.bz2 On Sat, 25 Nov 2017, Jakub Jelinek wrote: > Hi! > > As the testcases show, it is essential that bss_initializer_p returns > true for DECL_COMMON vars without initializer, even when they are > TREE_READONLY, otherwise they aren't really common, e.g. > if (DECL_COMMON (decl)) > { > /* If the decl has been given an explicit section name, or it resides > in a non-generic address space, then it isn't common, and shouldn't > be handled as such. */ > gcc_assert (DECL_SECTION_NAME (decl) == NULL > && ADDR_SPACE_GENERIC_P (as)); > if (DECL_THREAD_LOCAL_P (decl)) > return tls_comm_section; > else if (TREE_PUBLIC (decl) && bss_initializer_p (decl)) > return comm_section; > } > falls through into non-common code, and on section anchors target sometimes > ICE. > > Fixed thusly, bootstrapped/regtested on powerpc64le-linux, bootstrapped > also on {powerpc64,x86_64,i686}-linux, ok for trunk if the pending > regtests on the above 3 targets succeed? Ok. Richard. > 2017-11-24 Jakub Jelinek > > PR target/83100 > * varasm.c (bss_initializer_p): Return true for DECL_COMMON > TREE_READONLY decls. > > * gcc.dg/pr83100-1.c: New test. > * gcc.dg/pr83100-2.c: New test. > * gcc.dg/pr83100-3.c: New test. > * gcc.dg/pr83100-4.c: New test. > > --- gcc/varasm.c.jj 2017-11-21 20:23:02.000000000 +0100 > +++ gcc/varasm.c 2017-11-24 21:43:55.616951823 +0100 > @@ -986,9 +986,9 @@ decode_reg_name (const char *name) > bool > bss_initializer_p (const_tree decl) > { > - /* Do not put constants into the .bss section, they belong in a readonly > - section. */ > - return (!TREE_READONLY (decl) > + /* Do not put non-common constants into the .bss section, they belong in > + a readonly section. */ > + return ((!TREE_READONLY (decl) || DECL_COMMON (decl)) > && (DECL_INITIAL (decl) == NULL > /* In LTO we have no errors in program; error_mark_node is used > to mark offlined constructors. */ > --- gcc/testsuite/gcc.dg/pr83100-1.c.jj 2017-11-24 21:56:52.957497438 +0100 > +++ gcc/testsuite/gcc.dg/pr83100-1.c 2017-11-24 22:01:03.433437167 +0100 > @@ -0,0 +1,7 @@ > +/* PR target/83100 */ > +/* { dg-do compile { target *-*-linux* *-*-gnu* } } */ > +/* { dg-options "-O2 -fcommon -fdata-sections" } */ > + > +const int a; > + > +/* { dg-final { scan-assembler "comm" } } */ > --- gcc/testsuite/gcc.dg/pr83100-2.c.jj 2017-11-24 21:58:54.475012758 +0100 > +++ gcc/testsuite/gcc.dg/pr83100-2.c 2017-11-24 22:01:09.108367832 +0100 > @@ -0,0 +1,15 @@ > +/* PR target/83100 */ > +/* { dg-do run } */ > +/* { dg-options "-O2 -fcommon -fdata-sections" } */ > +/* { dg-additional-sources pr83100-3.c } */ > +/* { dg-skip-if "-fdata-sections not supported" { hppa*-*-hpux* nvptx-*-* } } */ > + > +const int a; > + > +int > +main () > +{ > + if (a != 7) > + __builtin_abort (); > + return 0; > +} > --- gcc/testsuite/gcc.dg/pr83100-3.c.jj 2017-11-24 21:59:57.072247956 +0100 > +++ gcc/testsuite/gcc.dg/pr83100-3.c 2017-11-24 22:01:14.344303860 +0100 > @@ -0,0 +1,6 @@ > +/* PR target/83100 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fcommon -fdata-sections" } */ > +/* { dg-skip-if "-fdata-sections not supported" { hppa*-*-hpux* nvptx-*-* } } */ > + > +const int a = 7; > --- gcc/testsuite/gcc.dg/pr83100-4.c.jj 2017-11-24 22:00:13.405048405 +0100 > +++ gcc/testsuite/gcc.dg/pr83100-4.c 2017-11-24 22:01:20.281231323 +0100 > @@ -0,0 +1,7 @@ > +/* PR target/83100 */ > +/* { dg-do compile { target *-*-linux* *-*-gnu* } } */ > +/* { dg-options "-O2 -fno-common -fdata-sections" } */ > + > +const int a; > + > +/* { dg-final { scan-assembler "rodata.a" } } */ > > Jakub > > -- Richard Biener SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)