diff options
author | Evgeny Karpov <Evgeny.Karpov@microsoft.com> | 2024-06-28 12:37:12 +0000 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@linaro.org> | 2024-06-28 12:47:13 +0000 |
commit | c4b7b62bfa10816c1e08f0f9597d857f11379688 (patch) | |
tree | 2f8b9cc0cb6e074bbd2c3aaa599fa3e8514558e9 | |
parent | e9aa97940c60cbd43f28d8b1292126e118ead1d9 (diff) | |
download | gcc-c4b7b62bfa10816c1e08f0f9597d857f11379688.zip gcc-c4b7b62bfa10816c1e08f0f9597d857f11379688.tar.gz gcc-c4b7b62bfa10816c1e08f0f9597d857f11379688.tar.bz2 |
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.
-rw-r--r-- | gcc/config/aarch64/cygming.h | 2 | ||||
-rw-r--r-- | gcc/config/i386/cygming.h | 7 | ||||
-rw-r--r-- | gcc/config/i386/i386-expand.cc | 5 | ||||
-rw-r--r-- | gcc/config/i386/i386-expand.h | 1 | ||||
-rw-r--r-- | gcc/config/i386/i386.cc | 11 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 2 | ||||
-rw-r--r-- | gcc/config/mingw/winnt-dll.cc | 4 | ||||
-rw-r--r-- | 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 e264887..9ce140a 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 0493b3b..9c8c7e3 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 dd2c3a8..a4434c1 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 5e02df1..56bee29 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 92e3c67..6f742ef 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 9ed225e..147b12c 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 66c445c..f74495b 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 14ca743..659d9c1 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); |