From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11962 invoked by alias); 27 Mar 2010 21:07:34 -0000 Received: (qmail 11948 invoked by uid 22791); 27 Mar 2010 21:07:32 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 27 Mar 2010 21:07:26 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 52BFD9ACC10; Sat, 27 Mar 2010 22:07:24 +0100 (CET) Date: Sat, 27 Mar 2010 21:48:00 -0000 From: Jan Hubicka To: John David Anglin Cc: Jan Hubicka , gcc-patches@gcc.gnu.org, rguenth@gcc.gnu.org Subject: Re: [PATCH] Fix visibility of constructors/destructors with Message-ID: <20100327210724.GA25821@kam.mff.cuni.cz> References: <20100327173211.GC19570@atrey.karlin.mff.cuni.cz> <20100327194940.774BB4EF1@hiauly1.hia.nrc.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100327194940.774BB4EF1@hiauly1.hia.nrc.ca> User-Agent: Mutt/1.5.18 (2008-05-17) 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 X-SW-Source: 2010-03/txt/msg01304.txt.bz2 > > Hmm, I see it was applied already, but this imply that attribute used on functions > > now imply externally_visible, while on variables it does not. > > It only implies externally_visible with -fwhole-program if the declaration > was originally externally visible. > > The documentation for attribute used says: > > @item used > @cindex @code{used} attribute. > This attribute, attached to a function, means that code must be emitted > for the function even if it appears that the function is not referenced. > This is useful, for example, when the function is referenced only in > inline assembly. Well, the manual says nothing about external visibility. It only says that you can reffer it from assembly (as given in the example bellow). I would say that for -fwhole-program we can still bring it local as long as all the assembly refering it is part of the unit and otherwise user is required to add the externally visible attribute same way as he has to add to anything else refered outside the unit compiled with -fwhole-program. "used" attribute is IMO intended primarily for static variables/functions refered from inline assembly. For functions referred from assembly in .s unit no decoration is needed. > > As can be seen, there is no mention on its effect on variables and > as far as I can tell the change didn't alter the visibility of variables > given that cgraph_externally_visible_p is not currently called for > variables. The documentation does not speak about variables, but since unit-at-a-time was introduced we support both (i.e. the unused/used attributes on both variables and functions) and they should behave symmetricaly. This change breaks the symmetry. Honza > > > I am not sure what would be best behaviour of used WRT whole-program. I guess > > the symbol should be still brought static, but the mangling (i.e. .1234) should > > not be applied so asm statements from other source files (within same LTO unit) > > can refer to it. > > > > I guess it is resonable to want something like the following work: > > > > t1.c: > > __attribute__ ((used)) int q; > > __attribute__ ((used)) > > void > > t() > > { > > } > > > > t2.c: > > main() > > { > > int q; > > asm("call t; movl $q,%0":"=r"(q)); > > return q; > > } > > > > and expect this to link properly -fwhole-program or not and I guess also to > > make -fwhole-program privatize both q and t unless externally_visible is given. > > > > At present (before this patch) we seem to get 't' right (i.e. it is static and > > with original name), but we do not output q. If this seems like intended > > behaviour, I guess I can fix this as well as make this hppa fix to attach > > externally visible attribute (or simply force externally visible flag on the > > cgraph node that should have same effect) > > The only reason I didn't try using the externally visible attribute was > attaching the attribute seemed tricky. > > Dave > -- > J. David Anglin dave.anglin@nrc-cnrc.gc.ca > National Research Council of Canada (613) 990-0752 (FAX: 952-6602)