From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27787 invoked by alias); 27 Mar 2010 19:49:51 -0000 Received: (qmail 27775 invoked by uid 22791); 27 Mar 2010 19:49:50 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from hiauly1.hia.nrc.ca (HELO hiauly1.hia.nrc.ca) (132.246.100.193) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 27 Mar 2010 19:49:42 +0000 Received: by hiauly1.hia.nrc.ca (Postfix, from userid 1000) id 774BB4EF1; Sat, 27 Mar 2010 15:49:40 -0400 (EDT) Subject: Re: [PATCH] Fix visibility of constructors/destructors with To: hubicka@ucw.cz (Jan Hubicka) Date: Sat, 27 Mar 2010 21:11:00 -0000 From: "John David Anglin" Cc: gcc-patches@gcc.gnu.org, rguenth@gcc.gnu.org In-Reply-To: <20100327173211.GC19570@atrey.karlin.mff.cuni.cz> from "Jan Hubicka" at Mar 27, 2010 06:32:11 pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20100327194940.774BB4EF1@hiauly1.hia.nrc.ca> 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/msg01303.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. 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. > 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)