From patchwork Sat Dec 25 18:48:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 76697 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D4445B70E8 for ; Sun, 26 Dec 2010 05:48:19 +1100 (EST) Received: (qmail 5441 invoked by alias); 25 Dec 2010 18:48:17 -0000 Received: (qmail 5432 invoked by uid 22791); 25 Dec 2010 18:48:17 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-pv0-f175.google.com (HELO mail-pv0-f175.google.com) (74.125.83.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 25 Dec 2010 18:48:12 +0000 Received: by pvd12 with SMTP id 12so1645576pvd.20 for ; Sat, 25 Dec 2010 10:48:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.191.10 with SMTP id o10mr7099983wff.208.1293302889693; Sat, 25 Dec 2010 10:48:09 -0800 (PST) Received: by 10.143.4.16 with HTTP; Sat, 25 Dec 2010 10:48:09 -0800 (PST) In-Reply-To: References: <4D0FC4B3.6040107@redhat.com> <4D10D81B.8010104@redhat.com> Date: Sat, 25 Dec 2010 19:48:09 +0100 Message-ID: Subject: Re: Fix 64-bit Solaris 2/x86 IE TLS code sequence (PR target/43309) From: Uros Bizjak To: Rainer Orth Cc: Richard Henderson , gcc-patches@gcc.gnu.org Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Wed, Dec 22, 2010 at 3:34 PM, Rainer Orth wrote: > Richard Henderson writes: > >> I thought that might happen, Uros.  You can't split the patterns >> for Sun ld. > > How should we proceed from here?  Return to my version of the patch? > While performing a x86_64-unknown-linux-gnu bootstrap for good measure, > I noticed that there's a problem there: bootstrap fails like this: > > /var/gcc/src/hg/trunk/solaris/gcc/config/i386/i386.c: In function 'legitimize_tls_address': > /var/gcc/src/hg/trunk/solaris/gcc/config/i386/i386.c:12551:4: error: implicit declaration of function 'gen_tls_initial_exec_64_sun' [-Werror=implicit-function-declaration] > /var/gcc/src/hg/trunk/solaris/gcc/config/i386/i386.c:12551:4: error: passing argument 1 of 'emit_insn' makes pointer from integer without a cast [-Werror] > /var/gcc/src/hg/trunk/solaris/gcc/rtl.h:1725:12: note: expected 'rtx' but argument is of type 'int' > cc1: all warnings being treated as errors > > make[3]: *** [i386.o] Error 1 > > gen_tls_initial_exec_64_sun isn't declared in insn-flags.h, probably > because TARGET_SUN_TLS is 0 in i386.h.  What's the best way to avoid > this?  Wrap the TARGET_64BIT && TARGET_SUN_TLS section in i386.c > (legitimize_tls_address) in #if TARGET_SUN_TLS? Attached variant of your original patch works for me - I have bootstrapped and regression test the patch on x86_64-pc-linux-gnu. Uros. Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 168243) +++ config/i386/i386.md (working copy) @@ -93,6 +93,7 @@ UNSPEC_TLS_GD UNSPEC_TLS_LD_BASE UNSPEC_TLSDESC + UNSPEC_TLS_IE_SUN ;; Other random patterns UNSPEC_SCAS @@ -12686,6 +12687,18 @@ (set_attr "memory" "load") (set_attr "imm_disp" "false")]) +;; The SUN linker took the AMD64 TLS spec literally and can only handle +;; %rax as destination of the initial executable code sequence. +(define_insn "tls_initial_exec_64_sun" + [(set (match_operand:DI 0 "register_operand" "=a") + (unspec:DI + [(match_operand:DI 1 "tls_symbolic_operand" "")] + UNSPEC_TLS_IE_SUN)) + (clobber (reg:CC FLAGS_REG))] + "TARGET_64BIT && TARGET_SUN_TLS" + "mov{q}\t{%%fs:0, %0|%0, QWORD PTR fs:0}\n\tadd{q}\t{%a1@gottpoff(%%rip), %0|%0, %a1@gottpoff[rip]}" + [(set_attr "type" "multi")]) + ;; GNU2 TLS patterns can be split. (define_expand "tls_dynamic_gnu2_32" Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 168243) +++ config/i386/i386.c (working copy) @@ -12542,6 +12542,17 @@ case TLS_MODEL_INITIAL_EXEC: if (TARGET_64BIT) { + if (TARGET_SUN_TLS) + { + /* The SUN linker took the AMD64 TLS spec literally + and can only handle %rax as destination of the + initial executable code sequence. */ + + dest = gen_reg_rtx (Pmode); + emit_insn (gen_tls_initial_exec_64_sun (dest, x)); + return dest; + } + pic = NULL; type = UNSPEC_GOTNTPOFF; }