[gcc r15-1708] i386: Fix regression after refactoring legitimize_pe_coff_symbol, ix86_GOT_alias_set and PE_COFF_LEG
Christophe Lyon
clyon@gcc.gnu.org
Fri Jun 28 12:47:36 GMT 2024
https://gcc.gnu.org/g:c4b7b62bfa10816c1e08f0f9597d857f11379688
commit r15-1708-gc4b7b62bfa10816c1e08f0f9597d857f11379688
Author: Evgeny Karpov <Evgeny.Karpov@microsoft.com>
Date: Fri Jun 28 12:37:12 2024 +0000
i386: Fix regression after refactoring legitimize_pe_coff_symbol, ix86_GOT_alias_set and PE_COFF_LEGITIMIZE_EXTERN_DECL [PR115635]
This patch fixes 3 bugs reported after merging the "Add DLL
import/export implementation to AArch64" series.
https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653955.html The
series refactors the i386 codebase to reuse it in AArch64, which
triggers some bugs.
Bug 115661 - [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu
since r15-1599-g63512c72df09b4
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
Bug 115635 - [15 regression] Bootstrap fails with failed self-test
with the rust fe (diagnostic-path.cc:1153: test_empty_path: FAIL:
ASSERT_FALSE ((path.interprocedural_p ()))) since
r15-1599-g63512c72df09b4
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115635
Issue 1. In some code, i386 has been relying on the
legitimize_pe_coff_symbol call on all platforms and should return
NULL_RTX if it is not supported.
Fix: NULL_RTX handling has been added when the target does not support
PECOFF.
Issue 2. ix86_GOT_alias_set is used on all platforms and cannot be
extracted to mingw.
Fix: ix86_GOT_alias_set has been returned as it was and is used on all
platforms for i386.
Bug 115643 - [15 regression] aarch64-w64-mingw32 support today breaks
x86_64-w64-mingw32 build cannot represent relocation type BFD_RELOC_64
since r15-1602-ged20feebd9ea31
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115643
Issue 3. PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED has been added and
used with a negative operator for a complex expression without braces.
Fix: Braces has been added, and
PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED has been renamed to
PE_COFF_LEGITIMIZE_EXTERN_DECL.
2024-06-28 Evgeny Karpov <Evgeny.Karpov@microsoft.com>
gcc/ChangeLog:
PR bootstrap/115635
PR target/115643
PR target/115661
* config/aarch64/cygming.h
(PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED): Rename to
PE_COFF_LEGITIMIZE_EXTERN_DECL.
(PE_COFF_LEGITIMIZE_EXTERN_DECL): Likewise.
* config/i386/cygming.h (GOT_ALIAS_SET): Remove the diffinition to
reuse it from i386.h.
(PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED): Rename to
PE_COFF_LEGITIMIZE_EXTERN_DECL.
(PE_COFF_LEGITIMIZE_EXTERN_DECL): Likewise.
* config/i386/i386-expand.cc (ix86_expand_move): Return
ix86_GOT_alias_set.
* config/i386/i386-expand.h (ix86_GOT_alias_set): Likewise.
* config/i386/i386.cc (ix86_GOT_alias_set): Likewise.
* config/i386/i386.h (GOT_ALIAS_SET): Likewise.
* config/mingw/winnt-dll.cc (get_dllimport_decl): Use
GOT_ALIAS_SET.
(legitimize_pe_coff_symbol): Rename to
PE_COFF_LEGITIMIZE_EXTERN_DECL.
* config/mingw/winnt-dll.h (ix86_GOT_alias_set): Declare
ix86_GOT_alias_set.
Diff:
---
gcc/config/aarch64/cygming.h | 2 +-
gcc/config/i386/cygming.h | 7 ++-----
gcc/config/i386/i386-expand.cc | 5 ++++-
gcc/config/i386/i386-expand.h | 1 +
gcc/config/i386/i386.cc | 11 +++++++++++
gcc/config/i386/i386.h | 2 +-
gcc/config/mingw/winnt-dll.cc | 4 ++--
gcc/config/mingw/winnt-dll.h | 1 +
8 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/gcc/config/aarch64/cygming.h b/gcc/config/aarch64/cygming.h
index e26488735db..9ce140a356f 100644
--- a/gcc/config/aarch64/cygming.h
+++ b/gcc/config/aarch64/cygming.h
@@ -186,7 +186,7 @@ still needed for compilation. */
#undef GOT_ALIAS_SET
#define GOT_ALIAS_SET mingw_GOT_alias_set ()
-#define PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED 1
+#define PE_COFF_LEGITIMIZE_EXTERN_DECL 1
#define HAVE_64BIT_POINTERS 1
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 0493b3be875..9c8c7e33cc2 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -470,10 +470,7 @@ do { \
# define HAVE_GAS_ALIGNED_COMM 0
#endif
-#undef GOT_ALIAS_SET
-#define GOT_ALIAS_SET mingw_GOT_alias_set ()
-
-#define PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED \
- ix86_cmodel == CM_LARGE_PIC || ix86_cmodel == CM_MEDIUM_PIC
+#define PE_COFF_LEGITIMIZE_EXTERN_DECL \
+ (ix86_cmodel == CM_LARGE_PIC || ix86_cmodel == CM_MEDIUM_PIC)
#define HAVE_64BIT_POINTERS TARGET_64BIT_DEFAULT
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index dd2c3a8718e..a4434c19272 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -414,6 +414,10 @@ ix86_expand_move (machine_mode mode, rtx operands[])
{
#if TARGET_PECOFF
tmp = legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
+#else
+ tmp = NULL_RTX;
+#endif
+
if (tmp)
{
op1 = tmp;
@@ -425,7 +429,6 @@ ix86_expand_move (machine_mode mode, rtx operands[])
op1 = operands[1];
break;
}
-#endif
}
if (addend)
diff --git a/gcc/config/i386/i386-expand.h b/gcc/config/i386/i386-expand.h
index 5e02df1706d..56bee29253b 100644
--- a/gcc/config/i386/i386-expand.h
+++ b/gcc/config/i386/i386-expand.h
@@ -34,6 +34,7 @@ struct expand_vec_perm_d
};
rtx legitimize_tls_address (rtx x, enum tls_model model, bool for_mov);
+alias_set_type ix86_GOT_alias_set (void);
rtx legitimize_pic_address (rtx orig, rtx reg);
bool insn_defines_reg (unsigned int regno1, unsigned int regno2,
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 92e3c67112e..6f742ef8231 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -11242,6 +11242,17 @@ ix86_cannot_force_const_mem (machine_mode mode, rtx x)
return !ix86_legitimate_constant_p (mode, x);
}
+/* Return a unique alias set for the GOT. */
+
+alias_set_type
+ix86_GOT_alias_set (void)
+{
+ static alias_set_type set = -1;
+ if (set == -1)
+ set = new_alias_set ();
+ return set;
+}
+
/* Nonzero if the constant value X is a legitimate general operand
when generating PIC code. It is given that flag_pic is on and
that X satisfies CONSTANT_P. */
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 9ed225ec587..147b12cd014 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2259,7 +2259,7 @@ extern int const svr4_debugger_register_map[FIRST_PSEUDO_REGISTER];
/* Which processor to tune code generation for. These must be in sync
with processor_cost_table in i386-options.cc. */
-#define GOT_ALIAS_SET -1
+#define GOT_ALIAS_SET ix86_GOT_alias_set ()
enum processor_type
{
diff --git a/gcc/config/mingw/winnt-dll.cc b/gcc/config/mingw/winnt-dll.cc
index 66c445cba77..f74495b7fda 100644
--- a/gcc/config/mingw/winnt-dll.cc
+++ b/gcc/config/mingw/winnt-dll.cc
@@ -139,7 +139,7 @@ get_dllimport_decl (tree decl, bool beimport)
}
rtl = gen_const_mem (Pmode, rtl);
- set_mem_alias_set (rtl, mingw_GOT_alias_set ());
+ set_mem_alias_set (rtl, GOT_ALIAS_SET);
SET_DECL_RTL (to, rtl);
SET_DECL_ASSEMBLER_NAME (to, get_identifier (name));
@@ -206,7 +206,7 @@ legitimize_pe_coff_symbol (rtx addr, bool inreg)
}
}
- if (!PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED)
+ if (!PE_COFF_LEGITIMIZE_EXTERN_DECL)
return NULL_RTX;
if (GET_CODE (addr) == SYMBOL_REF
diff --git a/gcc/config/mingw/winnt-dll.h b/gcc/config/mingw/winnt-dll.h
index 14ca743b69f..659d9c16b7c 100644
--- a/gcc/config/mingw/winnt-dll.h
+++ b/gcc/config/mingw/winnt-dll.h
@@ -22,6 +22,7 @@ http://www.gnu.org/licenses/. */
#ifndef USED_FOR_TARGET
extern bool is_imported_p (rtx x);
+extern alias_set_type ix86_GOT_alias_set (void);
extern alias_set_type mingw_GOT_alias_set (void);
extern rtx legitimize_pe_coff_symbol (rtx addr, bool inreg);
More information about the Gcc-cvs
mailing list