diff mbox

[i386,windows] : Fix weak-symbol support for 64-bit windows target

Message ID AANLkTi=3H85MDXYOogrAN1siKqzUiMegir_b1Ck28Sc9@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu Nov. 6, 2010, 4:08 a.m. UTC
On Fri, Nov 5, 2010 at 5:39 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Nov 5, 2010 at 5:36 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Fri, Nov 5, 2010 at 4:01 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> 2010/11/5 Richard Henderson <rth@redhat.com>:
>>>> On 11/04/2010 12:57 PM, Kai Tietz wrote:
>>>>> Here is the updated patch for x64 weak symbols (for static libraries).
>>>>> Prior patch misused the UNSPEC_GOTPCREL for expressing a pc-relative
>>>>> only. I added for this to i386.md the new UNSPEC_PCREL and added
>>>>> necessary checks to i386.c for handling new pic_address more correct.
>>>>>
>>>>> Tested for x86_64-w64-mingw32. Ok for apply?
>>>>
>>>> For 4.7, I'd like to investigate removing the flag_pic hack which
>>>> is causing some of this ugliness.
>>>
>>> Agreed.
>>>
>>>> But for the purposes of 4.6 this patch is ok.
>>>
>>> Committed at revision 166382.
>>>
>>
>> This patch is bogus. See:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46326
>>
>
>
> Did you mean
>
>     if (GET_CODE (x) != CONST
>          || GET_CODE (XEXP (x, 0)) != UNSPEC
>          || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
>              && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL)
>          || !MEM_P (orig_x))
>        return ix86_delegitimize_tls_address (orig_x);
>

Looking the patch at

http://gcc.gnu.org/ml/gcc-patches/2010-11/msg00454.html

@@ -11718,6 +11718,7 @@ legitimate_pic_address_disp_p (rtx disp)
       if (GET_CODE (disp) != UNSPEC
 	  || (XINT (disp, 1) != UNSPEC_GOTPCREL
 	      && XINT (disp, 1) != UNSPEC_GOTOFF
+	      && XINT (disp, 1) != UNSPEC_PCREL
 	      && XINT (disp, 1) != UNSPEC_PLTOFF))
 	return false;

@@ -13091,7 +13110,8 @@ ix86_find_base_term (rtx x)
 	      || GET_CODE (XEXP (term, 1)) == CONST_DOUBLE))
 	term = XEXP (term, 0);
       if (GET_CODE (term) != UNSPEC
-	  || XINT (term, 1) != UNSPEC_GOTPCREL)
+	  || (XINT (term, 1) != UNSPEC_GOTPCREL
+	      && XINT (term, 1) != UNSPEC_PCREL))
 	return x;

       return XVECEXP (term, 0, 0);
@@ -21794,6 +21814,7 @@ memory_address_length (rtx addr)
 		  || SYMBOL_REF_TLS_MODEL (symbol) != 0)
 	      && (GET_CODE (symbol) != UNSPEC
 		  || (XINT (symbol, 1) != UNSPEC_GOTPCREL
+		      && XINT (symbol, 1) != UNSPEC_PCREL
 		      && XINT (symbol, 1) != UNSPEC_GOTNTPOFF)))
 	    len += 1;
 	}

this is what was intended. I am checking it in as an obvious fix.

Comments

Kai Tietz Nov. 6, 2010, 6:34 a.m. UTC | #1
2010/11/6 H.J. Lu <hjl.tools@gmail.com>:
> On Fri, Nov 5, 2010 at 5:39 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Fri, Nov 5, 2010 at 5:36 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Fri, Nov 5, 2010 at 4:01 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>> 2010/11/5 Richard Henderson <rth@redhat.com>:
>>>>> On 11/04/2010 12:57 PM, Kai Tietz wrote:
>>>>>> Here is the updated patch for x64 weak symbols (for static libraries).
>>>>>> Prior patch misused the UNSPEC_GOTPCREL for expressing a pc-relative
>>>>>> only. I added for this to i386.md the new UNSPEC_PCREL and added
>>>>>> necessary checks to i386.c for handling new pic_address more correct.
>>>>>>
>>>>>> Tested for x86_64-w64-mingw32. Ok for apply?
>>>>>
>>>>> For 4.7, I'd like to investigate removing the flag_pic hack which
>>>>> is causing some of this ugliness.
>>>>
>>>> Agreed.
>>>>
>>>>> But for the purposes of 4.6 this patch is ok.
>>>>
>>>> Committed at revision 166382.
>>>>
>>>
>>> This patch is bogus. See:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46326
>>>
>>
>>
>> Did you mean
>>
>>     if (GET_CODE (x) != CONST
>>          || GET_CODE (XEXP (x, 0)) != UNSPEC
>>          || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
>>              && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL)
>>          || !MEM_P (orig_x))
>>        return ix86_delegitimize_tls_address (orig_x);
>>
>
> Looking the patch at
>
> http://gcc.gnu.org/ml/gcc-patches/2010-11/msg00454.html
>
> @@ -11718,6 +11718,7 @@ legitimate_pic_address_disp_p (rtx disp)
>       if (GET_CODE (disp) != UNSPEC
>          || (XINT (disp, 1) != UNSPEC_GOTPCREL
>              && XINT (disp, 1) != UNSPEC_GOTOFF
> +             && XINT (disp, 1) != UNSPEC_PCREL
>              && XINT (disp, 1) != UNSPEC_PLTOFF))
>        return false;
>
> @@ -13091,7 +13110,8 @@ ix86_find_base_term (rtx x)
>              || GET_CODE (XEXP (term, 1)) == CONST_DOUBLE))
>        term = XEXP (term, 0);
>       if (GET_CODE (term) != UNSPEC
> -         || XINT (term, 1) != UNSPEC_GOTPCREL)
> +         || (XINT (term, 1) != UNSPEC_GOTPCREL
> +             && XINT (term, 1) != UNSPEC_PCREL))
>        return x;
>
>       return XVECEXP (term, 0, 0);
> @@ -21794,6 +21814,7 @@ memory_address_length (rtx addr)
>                  || SYMBOL_REF_TLS_MODEL (symbol) != 0)
>              && (GET_CODE (symbol) != UNSPEC
>                  || (XINT (symbol, 1) != UNSPEC_GOTPCREL
> +                     && XINT (symbol, 1) != UNSPEC_PCREL
>                      && XINT (symbol, 1) != UNSPEC_GOTNTPOFF)))
>            len += 1;
>        }
>
> this is what was intended. I am checking it in as an obvious fix.
>
>
> --
> H.J.
> ----
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 75d23de..f69622d 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,9 @@
> +2010-11-05  H.J. Lu  <hongjiu.lu@intel.com>
> +
> +       PR target/46326
> +       * config/i386/i386.c (ix86_delegitimize_address): Fix a typo
> +       in the last change.
> +
>  2010-11-05  Ian Lance Taylor  <iant@google.com>
>
>        * explow.c (allocate_dynamic_stack_space): Check
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index c50fcc2..6e086bc 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -13012,8 +13012,8 @@ ix86_delegitimize_address (rtx x)
>     {
>       if (GET_CODE (x) != CONST
>          || GET_CODE (XEXP (x, 0)) != UNSPEC
> -         || XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
> -         || XINT (XEXP (x, 0), 1) != UNSPEC_PCREL
> +         || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
> +             && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL)
>          || !MEM_P (orig_x))
>        return ix86_delegitimize_tls_address (orig_x);
>       x = XVECEXP (XEXP (x, 0), 0, 0);
>

Thanks,
Kai
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 75d23de..f69622d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@ 
+2010-11-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR target/46326
+	* config/i386/i386.c (ix86_delegitimize_address): Fix a typo
+	in the last change.
+
 2010-11-05  Ian Lance Taylor  <iant@google.com>

 	* explow.c (allocate_dynamic_stack_space): Check
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index c50fcc2..6e086bc 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13012,8 +13012,8 @@  ix86_delegitimize_address (rtx x)
     {
       if (GET_CODE (x) != CONST
 	  || GET_CODE (XEXP (x, 0)) != UNSPEC
-	  || XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
-	  || XINT (XEXP (x, 0), 1) != UNSPEC_PCREL
+	  || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
+	      && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL)
 	  || !MEM_P (orig_x))
 	return ix86_delegitimize_tls_address (orig_x);
       x = XVECEXP (XEXP (x, 0), 0, 0);