From patchwork Fri Jan 7 15:41:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 77889 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 2407DB70DA for ; Sat, 8 Jan 2011 02:41:43 +1100 (EST) Received: (qmail 4159 invoked by alias); 7 Jan 2011 15:41:41 -0000 Received: (qmail 4150 invoked by uid 22791); 7 Jan 2011 15:41:39 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, TW_ZJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Jan 2011 15:41:34 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 9F1DE84B; Fri, 7 Jan 2011 16:41:32 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Wq+BC50DT4De; Fri, 7 Jan 2011 16:41:28 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 4092484A; Fri, 7 Jan 2011 16:41:28 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p07FfRP6020184; Fri, 7 Jan 2011 16:41:27 +0100 (MET) From: Rainer Orth To: Uros Bizjak Cc: Richard Henderson , gcc-patches@gcc.gnu.org Subject: Re: Fix 64-bit Solaris 2/x86 IE TLS code sequence (PR target/43309) References: <4D0FC4B3.6040107@redhat.com> <4D10D81B.8010104@redhat.com> Date: Fri, 07 Jan 2011 16:41:27 +0100 In-Reply-To: (Uros Bizjak's message of "Thu, 6 Jan 2011 20:37:51 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes 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 Uros Bizjak writes: >> Ok for mainline now and the obvious backport (replacing define_c_enum >> with define_constants) for the 4.4 and 4.5 branches after testing? > >> PR target/43309 >> * config/i386/i386.c (legitimize_tls_address) >> : Handle TARGET_64BIT && TARGET_SUN_TLS. >> * config/i386/i386.md (UNSPEC_TLS_IE_SUN): Declare. >> (tls_initial_exec_64_sun): New pattern. > > Yes, this is OK everywhere. The change mentioned above was sufficient for the 4.5 backport, for the 4.4 branch I needed to backport another patch that provides TARGET_SUN_TLS. Bootstrapped without regressions on i386-pc-solaris2.10 with Sun as (where Sun as TLS support has been implemented) on the 4.5 branch, and on i386-pc-solaris2.10 with gas (no Sun as TLS support) on the 4.4 branch. Here's the patch I commited to the 4.4 branch; the 4.5 backport is just a subset. Thanks. Rainer 2011-01-07 Rainer Orth Backport from mainline: 2011-01-06 Rainer Orth PR target/43309 * config/i386/i386.c (legitimize_tls_address) : Handle TARGET_64BIT && TARGET_SUN_TLS. * config/i386/i386.md (UNSPEC_TLS_IE_SUN): Declare. (tls_initial_exec_64_sun): New pattern. 2010-03-24 Rainer Orth * config/i386/i386.c (override_options): Don't accept -mtls-dialect=sun any longer. * config/i386/i386.h (TARGET_SUN_TLS): Define as 0. * config/i386/i386.md (*tls_global_dynamic_32_sun): Remove. (*tls_local_dynamic_base_32_sun): Likewise. * config/i386/sol2.h (TARGET_SUN_TLS): Redefine. diff -r 6f55ec0912e2 gcc/config/i386/i386.c --- a/gcc/config/i386/i386.c Thu Jan 06 21:03:28 2011 +0100 +++ b/gcc/config/i386/i386.c Fri Jan 07 16:24:27 2011 +0100 @@ -2999,8 +2999,6 @@ ix86_tls_dialect = TLS_DIALECT_GNU; else if (strcmp (ix86_tls_dialect_string, "gnu2") == 0) ix86_tls_dialect = TLS_DIALECT_GNU2; - else if (strcmp (ix86_tls_dialect_string, "sun") == 0) - ix86_tls_dialect = TLS_DIALECT_SUN; else error ("bad value (%s) for %stls-dialect=%s %s", ix86_tls_dialect_string, prefix, suffix, sw); @@ -9869,6 +9867,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; } diff -r 6f55ec0912e2 gcc/config/i386/i386.h --- a/gcc/config/i386/i386.h Thu Jan 06 21:03:28 2011 +0100 +++ b/gcc/config/i386/i386.h Fri Jan 07 16:24:27 2011 +0100 @@ -1,6 +1,6 @@ /* Definitions of target machine for GCC for IA-32. Copyright (C) 1988, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -422,7 +422,7 @@ #define TARGET_GNU_TLS (ix86_tls_dialect == TLS_DIALECT_GNU) #define TARGET_GNU2_TLS (ix86_tls_dialect == TLS_DIALECT_GNU2) #define TARGET_ANY_GNU_TLS (TARGET_GNU_TLS || TARGET_GNU2_TLS) -#define TARGET_SUN_TLS (ix86_tls_dialect == TLS_DIALECT_SUN) +#define TARGET_SUN_TLS 0 extern int ix86_isa_flags; diff -r 6f55ec0912e2 gcc/config/i386/i386.md --- a/gcc/config/i386/i386.md Thu Jan 06 21:03:28 2011 +0100 +++ b/gcc/config/i386/i386.md Fri Jan 07 16:24:27 2011 +0100 @@ -1,6 +1,6 @@ ;; GCC machine description for IA-32 and x86-64. ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 ;; Free Software Foundation, Inc. ;; Mostly by William Schelter. ;; x86_64 support added by Jan Hubicka @@ -75,6 +75,7 @@ (UNSPEC_TLS_GD 21) (UNSPEC_TLS_LD_BASE 22) (UNSPEC_TLSDESC 23) + (UNSPEC_TLS_IE_SUN 24) ; Other random patterns (UNSPEC_EH_RETURN 29) @@ -15889,21 +15890,6 @@ [(set_attr "type" "multi") (set_attr "length" "12")]) -(define_insn "*tls_global_dynamic_32_sun" - [(set (match_operand:SI 0 "register_operand" "=a") - (unspec:SI [(match_operand:SI 1 "register_operand" "b") - (match_operand:SI 2 "tls_symbolic_operand" "") - (match_operand:SI 3 "call_insn_operand" "")] - UNSPEC_TLS_GD)) - (clobber (match_scratch:SI 4 "=d")) - (clobber (match_scratch:SI 5 "=c")) - (clobber (reg:CC FLAGS_REG))] - "!TARGET_64BIT && TARGET_SUN_TLS" - "lea{l}\t{%a2@DTLNDX(%1), %4|%4, %a2@DTLNDX[%1]} - push{l}\t%4\;call\t%a2@TLSPLT\;pop{l}\t%4\;nop" - [(set_attr "type" "multi") - (set_attr "length" "14")]) - (define_expand "tls_global_dynamic_32" [(parallel [(set (match_operand:SI 0 "register_operand" "") (unspec:SI @@ -15972,20 +15958,6 @@ [(set_attr "type" "multi") (set_attr "length" "11")]) -(define_insn "*tls_local_dynamic_base_32_sun" - [(set (match_operand:SI 0 "register_operand" "=a") - (unspec:SI [(match_operand:SI 1 "register_operand" "b") - (match_operand:SI 2 "call_insn_operand" "")] - UNSPEC_TLS_LD_BASE)) - (clobber (match_scratch:SI 3 "=d")) - (clobber (match_scratch:SI 4 "=c")) - (clobber (reg:CC FLAGS_REG))] - "!TARGET_64BIT && TARGET_SUN_TLS" - "lea{l}\t{%&@TMDNX(%1), %3|%3, %&@TMDNX[%1]} - push{l}\t%3\;call\t%&@TLSPLT\;pop{l}\t%3" - [(set_attr "type" "multi") - (set_attr "length" "13")]) - (define_expand "tls_local_dynamic_base_32" [(parallel [(set (match_operand:SI 0 "register_operand" "") (unspec:SI [(match_dup 1) (match_dup 2)] @@ -16111,6 +16083,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" diff -r 6f55ec0912e2 gcc/config/i386/sol2.h --- a/gcc/config/i386/sol2.h Thu Jan 06 21:03:28 2011 +0100 +++ b/gcc/config/i386/sol2.h Fri Jan 07 16:24:27 2011 +0100 @@ -91,6 +91,11 @@ } \ } while (0) +/* Follow Sun requirements for TLS code sequences and use Sun assembler TLS + syntax. */ +#undef TARGET_SUN_TLS +#define TARGET_SUN_TLS 1 + /* The Solaris assembler cannot grok .stabd directives. */ #undef NO_DBX_BNSYM_ENSYM #define NO_DBX_BNSYM_ENSYM 1