https://gcc.gnu.org/g:807e36d76e5105015afe0cf20e9a8837bb550f4b
commit r15-1867-g807e36d76e5105015afe0cf20e9a8837bb550f4b Author: Iain Sandoe <i...@sandoe.co.uk> Date: Fri Jul 5 09:26:40 2024 +0100 x86, Darwin: Fix bootstrap for 32b multilibs/hosts. r15-1735-ge62ea4fb8ffcab06ddd contained changes that altered the codegen for 32b Darwin (whether hosted on 64b or as 32b host) such that the per function picbase load is called multiple times in some cases. Darwin's back end is not expecting this (and indeed some of the handling depends on a single instance). The fixes the issue by marking those instructions as not copyable (as suggested by Andrew Pinski). The change is Darwin-specific. gcc/ChangeLog: * config/i386/i386.cc (ix86_cannot_copy_insn_p): New. (TARGET_CANNOT_COPY_INSN_P): New. Signed-off-by: Iain Sandoe <ia...@gcc.gnu.org> Diff: --- gcc/config/i386/i386.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 99def8d4a77..f75250f79de 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -27025,6 +27025,29 @@ ix86_libm_function_max_error (unsigned cfn, machine_mode mode, #undef TARGET_LIBM_FUNCTION_MAX_ERROR #define TARGET_LIBM_FUNCTION_MAX_ERROR ix86_libm_function_max_error +#if TARGET_MACHO +static bool +ix86_cannot_copy_insn_p (rtx_insn *insn) +{ + if (TARGET_64BIT) + return false; + + rtx set = single_set (insn); + if (set) + { + rtx src = SET_SRC (set); + if (GET_CODE (src) == UNSPEC + && XINT (src, 1) == UNSPEC_SET_GOT) + return true; + } + return false; +} + +#undef TARGET_CANNOT_COPY_INSN_P +#define TARGET_CANNOT_COPY_INSN_P ix86_cannot_copy_insn_p + +#endif + #if CHECKING_P #undef TARGET_RUN_TARGET_SELFTESTS #define TARGET_RUN_TARGET_SELFTESTS selftest::ix86_run_selftests