From patchwork Thu Jul 15 18:27:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [darwin] do not generate branch islands when the linker can do it. From: IainS X-Patchwork-Id: 59003 Message-Id: <8987CD7A-53F6-45B1-9A88-E27107B1AAFB@sandoe-acoustics.co.uk> To: Richard Henderson Cc: gcc-patches List , mrs@gcc.gnu.org, Uros Bizjak , David Edelsohn Date: Thu, 15 Jul 2010 19:27:36 +0100 On 15 Jul 2010, at 18:38, Richard Henderson wrote: > On 07/15/2010 10:10 AM, IainS wrote: >> - if (! TARGET_MACHO || TARGET_64BIT) >> + if (! TARGET_MACHO || >> +#if TARGET_MACHO >> + ! darwin_emit_branch_islands || >> +#endif >> + TARGET_64BIT) > > I'd really like to avoid the #if mid if. Perhaps > > if (TARGET_64BIT || !TARGET_MACHO_BRANCH_ISLANDS) > > with > > #if TARGET_MACHO > #define TARGET_MACHO_BRANCH_ISLANDS darwin_emit_branch_islands > #else > #define TARGET_MACHO_BRANCH_ISLANDS 0 > #endif > > or similar via #undef (I almost did that anyway .. not quite sure why I didn't now.. ) Iain ---- amendment (changes since first patch only); @@ -11510,7 +11514,7 @@ output_pic_addr_const (FILE *file, rtx x, int code break; case SYMBOL_REF: - if (! TARGET_MACHO || TARGET_64BIT) + if (! TARGET_MACHO || ! TARGET_MACHO_BRANCH_ISLANDS || TARGET_64BIT) output_addr_const (file, x); else { @@ -27230,10 +27234,11 @@ x86_output_mi_thunk (FILE *file, if (TARGET_MACHO) { rtx sym_ref = XEXP (DECL_RTL (function), 0); - tmp = (gen_rtx_SYMBOL_REF + if (TARGET_MACHO_BRANCH_ISLANDS) + sym_ref = (gen_rtx_SYMBOL_REF (Pmode, machopic_indirection_name (sym_ref, /*stub_p=*/true))); - tmp = gen_rtx_MEM (QImode, tmp); + tmp = gen_rtx_MEM (QImode, sym_ref); xops[0] = tmp; output_asm_insn ("jmp\t%0", xops); } Index: gcc/config/i386/darwin.h =================================================================== --- gcc/config/i386/darwin.h (revision 162209) +++ gcc/config/i386/darwin.h (working copy) @@ -60,6 +60,9 @@ along with GCC; see the file COPYING3. If not see #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE 32 +/* Generate branch islands stubs if this is true. */ +extern int darwin_emit_branch_islands; + #undef MAX_BITS_PER_WORD #define MAX_BITS_PER_WORD 64 @@ -225,7 +228,7 @@ along with GCC; see the file COPYING3. If not see #undef FUNCTION_PROFILER #define FUNCTION_PROFILER(FILE, LABELNO) \ do { \ - if (MACHOPIC_INDIRECT && !TARGET_64BIT) \ + if (darwin_emit_branch_islands && MACHOPIC_INDIRECT && ! TARGET_64BIT) \ { \ const char *name = machopic_mcount_stub_name (); \ fprintf (FILE, "\tcall %s\n", name+1); /* skip '&' */ \ @@ -300,3 +303,7 @@ along with GCC; see the file COPYING3. If not see #define MACHO_SYMBOL_FLAG_VARIABLE ((SYMBOL_FLAG_MACH_DEP) << 3) #define SUBTARGET32_DEFAULT_CPU "i686" + +#undef TARGET_MACHO_BRANCH_ISLANDS +#define TARGET_MACHO_BRANCH_ISLANDS darwin_emit_branch_islands + Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c (revision 162209) +++ gcc/config/i386/i386.c (working copy) @@ -2206,6 +2206,10 @@ static const char *const cpu_names[TARGET_CPU_DEFA "amdfam10", "bdver1" }; + +#ifndef TARGET_MACHO_BRANCH_ISLANDS +# define TARGET_MACHO_BRANCH_ISLANDS 0 +#endif /* Implement TARGET_HANDLE_OPTION. */