From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5225 invoked by alias); 6 Sep 2011 20:31:11 -0000 Received: (qmail 5213 invoked by uid 22791); 6 Sep 2011 20:31:10 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Sep 2011 20:30:54 +0000 Received: by ywa12 with SMTP id 12so4308159ywa.20 for ; Tue, 06 Sep 2011 13:30:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.177.69 with SMTP id c45mr26469542yhm.97.1315341053549; Tue, 06 Sep 2011 13:30:53 -0700 (PDT) Received: by 10.236.102.137 with HTTP; Tue, 6 Sep 2011 13:30:53 -0700 (PDT) In-Reply-To: References: Date: Tue, 06 Sep 2011 20:31:00 -0000 Message-ID: Subject: Re: TLS, gcc optimizations, and PIC on x86 From: Kevin Klues To: Ian Lance Taylor Cc: gcc-help@gcc.gnu.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00044.txt.bz2 It looks like 'optimize' is necessary in cases where I do something like: __thread int i =3D 0; i =3D 5; // Set variable in original tls region set_tls_desc(new_tls); i =3D 5; // Set variable in new tls region Where I set i equal to the same value, but in 2 different TLS regions. Glancing through the assembly, it appears that the code for the nested function indeed get's generated (as per the 'noinline'), but then it simply noops and returns. Kevin On Tue, Sep 6, 2011 at 12:09 AM, Ian Lance Taylor wrote: > Kevin Klues writes: > >> That said, do you see any obvious issues with my solution? =A0It seems >> to work for all of the test cases I've thrown at it, but I could be >> missing something. =A0Additionally, do you have any suggestions for a >> better method that achieves similar results? =A0Ideally I'd like a >> solution that didn't require the use of the 'optimize' attribute as >> (unfortunately) some of the systems on which we'd like to compile our >> code still use gcc < 4.4. > > I don't see any obvious issues with your solution. =A0I'm not sure why you > need to use the optimize attribute; I would have expected that the > noinline attribute would be sufficient here. > > Ian > --=20 ~K=80vin