[patch PR 51900]: Fix PE's delegitimize_address functions
Kai Tietz
ktietz70@googlemail.com
Mon Jan 23 13:11:00 GMT 2012
So revised patch with removing dwarf2out.c changes and using
default_binds_local_p_1 in i386_pe_binds_local_p. The dwarf2out
change isn't anymore necessary. It seems that fix of PR/45682 fixed
this issue, too.
ChangeLog
2012-01-23 Kai Tietz <ktietz@redhat.com>
PR target/51900
* config/i386/predicates.md (symbolic_operand): Allow
UNSPEC_PCREL as PIC expression for lea.
* config/i386/winnt.c (i386_pe_binds_local_p): Reworked.
* config/i386/i386.c (ix86_delegitimize_address): Handle
UNSPEC_PCREL for none-MEM, too.
Tested for x86_64-w64-mingw, i686-w64-mingw32, and
x86_64-unknown-linux-gnu. Ok for apply?
Regards,
Kai
Index: config/i386/predicates.md
===================================================================
--- config/i386/predicates.md (revision 183389)
+++ config/i386/predicates.md (working copy)
@@ -410,6 +410,7 @@
|| (GET_CODE (op) == UNSPEC
&& (XINT (op, 1) == UNSPEC_GOT
|| XINT (op, 1) == UNSPEC_GOTOFF
+ || XINT (op, 1) == UNSPEC_PCREL
|| XINT (op, 1) == UNSPEC_GOTPCREL)))
return true;
if (GET_CODE (op) != PLUS
Index: config/i386/winnt.c
===================================================================
--- config/i386/winnt.c (revision 183389)
+++ config/i386/winnt.c (working copy)
@@ -350,21 +350,22 @@
SYMBOL_REF_FLAGS (symbol) = flags;
}
+
bool
i386_pe_binds_local_p (const_tree exp)
{
- /* PE does not do dynamic binding. Indeed, the only kind of
- non-local reference comes from a dllimport'd symbol. */
if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
&& DECL_DLLIMPORT_P (exp))
return false;
- /* Or a weak one, now that they are supported. */
- if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
- && DECL_WEAK (exp))
- return false;
-
- return true;
+ /* External public symbols, which aren't weakref-s,
+ have local-binding for PE targets. */
+ if (DECL_P (exp)
+ && !lookup_attribute ("weakref", DECL_ATTRIBUTES (exp))
+ && TREE_PUBLIC (exp)
+ && DECL_EXTERNAL (exp))
+ return true;
+ return default_binds_local_p_1 (exp, 0);
}
/* Also strip the fastcall prefix and stdcall suffix. */
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 183389)
+++ config/i386/i386.c (working copy)
@@ -13231,10 +13231,10 @@
|| GET_CODE (XEXP (x, 0)) != UNSPEC
|| (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
&& XINT (XEXP (x, 0), 1) != UNSPEC_PCREL)
- || !MEM_P (orig_x))
+ || (!MEM_P (orig_x) && XINT (XEXP (x, 0), 1) != UNSPEC_PCREL))
return ix86_delegitimize_tls_address (orig_x);
x = XVECEXP (XEXP (x, 0), 0, 0);
- if (GET_MODE (orig_x) != GET_MODE (x))
+ if (GET_MODE (orig_x) != GET_MODE (x) && MEM_P (orig_x))
{
x = simplify_gen_subreg (GET_MODE (orig_x), x,
GET_MODE (x), 0);
More information about the Gcc-patches
mailing list