patches/gcc/4.8.2/110-fix-PR-target-58595.patch
changeset 3294 c65fcf8a34b7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/gcc/4.8.2/110-fix-PR-target-58595.patch	Thu Apr 17 18:17:12 2014 +0200
     1.3 @@ -0,0 +1,101 @@
     1.4 +Backport fix for PR target/58595
     1.5 +
     1.6 +From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
     1.7 +Date: Thu, 6 Mar 2014 12:07:07 +0000
     1.8 +Subject: [PATCH] 	PR target/58595 	* config/arm/arm.c
     1.9 + (arm_tls_symbol_p): Remove. 	(arm_legitimize_address): Call
    1.10 + legitimize_tls_address for any 	arm_tls_referenced_p expression,
    1.11 + handle constant addend.  Call it 	before testing for !TARGET_ARM. 
    1.12 + (thumb_legitimize_address): Don't handle arm_tls_symbol_p here.
    1.13 +
    1.14 +	* gcc.dg/tls/pr58595.c: New test.
    1.15 +
    1.16 +
    1.17 +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208380 138bc75d-0d04-0410-961f-82ee72b054a4
    1.18 +
    1.19 +Index: gcc-4.8.2/gcc/config/arm/arm.c
    1.20 +===================================================================
    1.21 +--- gcc-4.8.2.orig/gcc/config/arm/arm.c
    1.22 ++++ gcc-4.8.2/gcc/config/arm/arm.c
    1.23 +@@ -230,7 +230,6 @@ static tree arm_gimplify_va_arg_expr (tr
    1.24 + static void arm_option_override (void);
    1.25 + static unsigned HOST_WIDE_INT arm_shift_truncation_mask (enum machine_mode);
    1.26 + static bool arm_cannot_copy_insn_p (rtx);
    1.27 +-static bool arm_tls_symbol_p (rtx x);
    1.28 + static int arm_issue_rate (void);
    1.29 + static void arm_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
    1.30 + static bool arm_output_addr_const_extra (FILE *, rtx);
    1.31 +@@ -6573,6 +6572,32 @@ legitimize_tls_address (rtx x, rtx reg)
    1.32 + rtx
    1.33 + arm_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode)
    1.34 + {
    1.35 ++  if (arm_tls_referenced_p (x))
    1.36 ++    {
    1.37 ++      rtx addend = NULL;
    1.38 ++
    1.39 ++      if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS)
    1.40 ++	{
    1.41 ++	  addend = XEXP (XEXP (x, 0), 1);
    1.42 ++	  x = XEXP (XEXP (x, 0), 0);
    1.43 ++	}
    1.44 ++
    1.45 ++      if (GET_CODE (x) != SYMBOL_REF)
    1.46 ++	return x;
    1.47 ++
    1.48 ++      gcc_assert (SYMBOL_REF_TLS_MODEL (x) != 0);
    1.49 ++
    1.50 ++      x = legitimize_tls_address (x, NULL_RTX);
    1.51 ++
    1.52 ++      if (addend)
    1.53 ++	{
    1.54 ++	  x = gen_rtx_PLUS (SImode, x, addend);
    1.55 ++	  orig_x = x;
    1.56 ++	}
    1.57 ++      else
    1.58 ++	return x;
    1.59 ++    }
    1.60 ++
    1.61 +   if (!TARGET_ARM)
    1.62 +     {
    1.63 +       /* TODO: legitimize_address for Thumb2.  */
    1.64 +@@ -6581,9 +6606,6 @@ arm_legitimize_address (rtx x, rtx orig_
    1.65 +       return thumb_legitimize_address (x, orig_x, mode);
    1.66 +     }
    1.67 + 
    1.68 +-  if (arm_tls_symbol_p (x))
    1.69 +-    return legitimize_tls_address (x, NULL_RTX);
    1.70 +-
    1.71 +   if (GET_CODE (x) == PLUS)
    1.72 +     {
    1.73 +       rtx xop0 = XEXP (x, 0);
    1.74 +@@ -6695,9 +6717,6 @@ arm_legitimize_address (rtx x, rtx orig_
    1.75 + rtx
    1.76 + thumb_legitimize_address (rtx x, rtx orig_x, enum machine_mode mode)
    1.77 + {
    1.78 +-  if (arm_tls_symbol_p (x))
    1.79 +-    return legitimize_tls_address (x, NULL_RTX);
    1.80 +-
    1.81 +   if (GET_CODE (x) == PLUS
    1.82 +       && CONST_INT_P (XEXP (x, 1))
    1.83 +       && (INTVAL (XEXP (x, 1)) >= 32 * GET_MODE_SIZE (mode)
    1.84 +@@ -6988,20 +7007,6 @@ thumb_legitimize_reload_address (rtx *x_
    1.85 + 
    1.86 + /* Test for various thread-local symbols.  */
    1.87 + 
    1.88 +-/* Return TRUE if X is a thread-local symbol.  */
    1.89 +-
    1.90 +-static bool
    1.91 +-arm_tls_symbol_p (rtx x)
    1.92 +-{
    1.93 +-  if (! TARGET_HAVE_TLS)
    1.94 +-    return false;
    1.95 +-
    1.96 +-  if (GET_CODE (x) != SYMBOL_REF)
    1.97 +-    return false;
    1.98 +-
    1.99 +-  return SYMBOL_REF_TLS_MODEL (x) != 0;
   1.100 +-}
   1.101 +-
   1.102 + /* Helper for arm_tls_referenced_p.  */
   1.103 + 
   1.104 + static int