diff mbox

[x32] PATCH: PR target/47715: [x32] TLS doesn't work

Message ID 20110214183512.GA8296@intel.com
State New
Headers show

Commit Message

H.J. Lu Feb. 14, 2011, 6:35 p.m. UTC
On Sun, Feb 13, 2011 at 03:22:51PM -0800, H.J. Lu wrote:
> Hi,
> 
> ix86_expand_move has
> 
> tmp = expand_simple_binop (Pmode, PLUS, tmp, addend, op0, 1, OPTAB_DIRECT);
> if (tmp == op0)
>   return;
> 
> It never checks the case of tmp != op0.  This patch fixes it.
> 
> From 44741a1c97a7fec7c98702d217ac284856c75621 Mon Sep 17 00:00:00 2001
> From: H.J. Lu <hjl.tools@gmail.com>
> Date: Sun, 13 Feb 2011 15:09:50 -0800
> Subject: [PATCH 3/3] Properly support TLS symbol in ix86_expand_move.
> 
> ---
>  gcc/ChangeLog.x32                         |    6 ++++++
>  gcc/config/i386/i386.c                    |   26 +++++++++++++++++---------
>  gcc/testsuite/ChangeLog.x32               |    5 +++++
>  gcc/testsuite/gcc.target/i386/pr47715-3.c |   17 +++++++++++++++++
>  4 files changed, 45 insertions(+), 9 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr47715-3.c
> 
> diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
> index dda2a10..ec8aa23 100644
> --- a/gcc/ChangeLog.x32
> +++ b/gcc/ChangeLog.x32
> @@ -1,5 +1,11 @@
>  2011-02-13  H.J. Lu  <hongjiu.lu@intel.com>
>  
> +	PR target/47715
> +	* config/i386/i386.c (ix86_expand_move): Properly support TLS
> +	symbol.
> +
> +2011-02-13  H.J. Lu  <hongjiu.lu@intel.com>
> +
>  	* config/i386/morestack.S: Properly check __x86_64__ and
>  	__LP64__.
>  
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 63add39..9ceb5c0 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -15403,6 +15403,7 @@ void
>  ix86_expand_move (enum machine_mode mode, rtx operands[])
>  {
>    rtx op0, op1;
> +  rtx symbol1 = NULL;
>    enum tls_model model;
>  
>    op0 = operands[0];
> @@ -15430,21 +15431,20 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
>      {
>        rtx addend = XEXP (XEXP (op1, 0), 1);
>        rtx symbol = XEXP (XEXP (op1, 0), 0);
> -      rtx tmp = NULL;
>  
>        model = SYMBOL_REF_TLS_MODEL (symbol);
>        if (model)
> -	tmp = legitimize_tls_address (symbol, model, true);
> +	symbol1 = legitimize_tls_address (symbol, model, true);
>        else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
>  	       && SYMBOL_REF_DLLIMPORT_P (symbol))
> -	tmp = legitimize_dllimport_symbol (symbol, true);
> +	symbol1 = legitimize_dllimport_symbol (symbol, true);
>  
> -      if (tmp)
> +      if (symbol1)
>  	{
> -	  tmp = force_operand (tmp, NULL);
> -	  tmp = expand_simple_binop (Pmode, PLUS, tmp, addend,
> -				     op0, 1, OPTAB_DIRECT);
> -	  if (tmp == op0)
> +	  symbol1 = force_operand (symbol1, NULL);
> +	  symbol1 = expand_simple_binop (Pmode, PLUS, symbol1, addend,
> +					 op0, 1, OPTAB_DIRECT);
> +	  if (symbol1 == op0)
>  	    return;
>  	}
>      }
> @@ -15455,6 +15455,7 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
>      {
>        if (TARGET_MACHO && !TARGET_64BIT)
>  	{
> +	  gcc_assert (symbol1 == NULL);
>  #if TARGET_MACHO
>  	  /* dynamic-no-pic */
>  	  if (MACHOPIC_INDIRECT)
> @@ -15491,7 +15493,13 @@ ix86_expand_move (enum machine_mode mode, rtx operands[])
>  	}
>        else
>  	{
> -	  if (MEM_P (op0))
> +	  if (symbol1 != NULL)
> +	    {
> +	      op1 = symbol1;
> +	      if (GET_MODE (op1) != mode)
> +		op1 = convert_to_mode (mode, op1, 1);
> +	    }
> +	  else if (MEM_P (op0))
>  	    op1 = force_reg (mode, op1);
>  	  else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, mode))
>  	    {

I checked in this patch to update TLS symbol PIC support.


H.J.
---
diff mbox

Patch

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 170144)
+++ gcc/config/i386/i386.c	(working copy)
@@ -15493,12 +15493,8 @@  ix86_expand_move (enum machine_mode mode
       else
 	{
 	  if (symbol1 != NULL)
-	    {
-	      op1 = symbol1;
-	      if (GET_MODE (op1) != mode)
-		op1 = convert_to_mode (mode, op1, 1);
-	    }
-	  else if (MEM_P (op0))
+	    op1 = symbol1;
+	  if (MEM_P (op0))
 	    op1 = force_reg (mode, op1);
 	  else if (!TARGET_64BIT || !x86_64_movabs_operand (op1, mode))
 	    {
Index: gcc/ChangeLog.x32
===================================================================
--- gcc/ChangeLog.x32	(revision 170144)
+++ gcc/ChangeLog.x32	(working copy)
@@ -1,6 +1,12 @@ 
 2011-02-13  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47715
+	* config/i386/i386.c (ix86_expand_move): Update TLS symbol PIC
+	support.
+
+2011-02-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/47715
 	* config/i386/i386.c (ix86_expand_move): Properly support TLS
 	symbol.