]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
allow darwin branch island control depening on system version
authorIain Sandoe <iains@gcc.gnu.org>
Mon, 19 Jul 2010 09:11:12 +0000 (09:11 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Mon, 19 Jul 2010 09:11:12 +0000 (09:11 +0000)
* config/i386/darwin.h: Define darwin_emit_branch_islands.
(TARGET_MACHO_BRANCH_ISLANDS): New.
(FUNCTION_PROFILER): Use TARGET_MACHO_BRANCH_ISLANDS.
* config/i386/i386.h (TARGET_MACHO_BRANCH_ISLANDS): Define a
default value.
* config/i386/i386.c (output_pic_addr_const): Do not emit
branch islands unless TARGET_MACHO_BRANCH_ISLANDS is set.
(x86_output_mi_thunk): Adjust symbol creation.
* config/rs6000/darwin.h: Define darwin_emit_branch_islands.
Remove out of date comment.
* config/rs6000/rs6000.c (print_operand): Adjust symbol.
DARWIN_LINKER_GENERATES_ISLANDS: Remove.
DARWIN_GENERATE_ISLANDS: Ditto.
(output_call):  Do not emit branch islands unless
darwin_emit_branch_islands is set.
* config/darwin.c: Declare darwin_emit_branch_islands.
(machopic_indirect_data_reference): Do not emit unless
darwin_emit_branch_islands is set.
(darwin_override_options): Set darwin_emit_branch_islands
where it is needed.
* config/darwin9.h
DARWIN_LINKER_GENERATES_ISLANDS: Remove.

From-SVN: r162299

gcc/ChangeLog
gcc/config/darwin.c
gcc/config/darwin9.h
gcc/config/i386/darwin.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/config/rs6000/darwin.h
gcc/config/rs6000/rs6000.c

index 0482650095e360c4509a5030068a42ce13471c4d..3384d60b428b694f075a212392103a835436079a 100644 (file)
@@ -1,3 +1,28 @@
+2010-07-19  Iain Sandoe  <iains@gcc.gnu.org>
+
+       * config/i386/darwin.h: Define darwin_emit_branch_islands.
+       (TARGET_MACHO_BRANCH_ISLANDS): New.
+       (FUNCTION_PROFILER): Use TARGET_MACHO_BRANCH_ISLANDS.
+       * config/i386/i386.h (TARGET_MACHO_BRANCH_ISLANDS): Define a
+       default value.
+       * config/i386/i386.c (output_pic_addr_const): Do not emit
+       branch islands unless TARGET_MACHO_BRANCH_ISLANDS is set.
+       (x86_output_mi_thunk): Adjust symbol creation.
+       * config/rs6000/darwin.h: Define darwin_emit_branch_islands.
+       Remove out of date comment.
+       * config/rs6000/rs6000.c (print_operand): Adjust symbol.
+       DARWIN_LINKER_GENERATES_ISLANDS: Remove.
+       DARWIN_GENERATE_ISLANDS: Ditto.
+       (output_call):  Do not emit branch islands unless
+       darwin_emit_branch_islands is set.
+       * config/darwin.c: Declare darwin_emit_branch_islands.
+       (machopic_indirect_data_reference): Do not emit unless
+       darwin_emit_branch_islands is set.
+       (darwin_override_options): Set darwin_emit_branch_islands
+       where it is needed.
+       * config/darwin9.h
+       DARWIN_LINKER_GENERATES_ISLANDS: Remove.
+
 2010-07-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * doc/sourcebuild.texi (Effective-Target Keywords): Document
index 952539f2aa9b3a97b8391551909db9b6c0908b43..59c603fb4a2d9a0e9592641580c09edc385a1e9b 100644 (file)
@@ -79,6 +79,12 @@ along with GCC; see the file COPYING3.  If not see
    of MACHO_SYMBOL_STATIC for the code that handles @code{static}
    symbol indirection.  */
 
+/* For darwin >= 9  (OSX 10.5) the linker is capable of making the necessary
+   branch islands and we no longer need to emit darwin stubs.
+   However, if we are generating code for earlier systems (or for use in the 
+   kernel) the stubs might still be required, and this will be set true.  */
+int darwin_emit_branch_islands = false;
+
 /* Section names.  */
 section * darwin_sections[NUM_DARWIN_SECTIONS];
 
@@ -625,6 +631,9 @@ machopic_indirect_data_reference (rtx orig, rtx reg)
 rtx
 machopic_indirect_call_target (rtx target)
 {
+  if (! darwin_emit_branch_islands)
+    return target;
+
   if (GET_CODE (target) != MEM)
     return target;
 
@@ -1888,12 +1897,19 @@ darwin_override_options (void)
       flag_exceptions = 0;
       /* No -fnon-call-exceptions data in kexts.  */
       flag_non_call_exceptions = 0;
+      /* We still need to emit branch islands for kernel context.  */
+      darwin_emit_branch_islands = true;
     }
   if (flag_var_tracking
       && strverscmp (darwin_macosx_version_min, "10.5") >= 0
       && debug_info_level >= DINFO_LEVEL_NORMAL
       && debug_hooks->var_location != do_nothing_debug_hooks.var_location)
     flag_var_tracking_uninit = 1;
+
+  /* It is assumed that branch island stubs are needed for earlier systems.  */
+  if (darwin_macosx_version_min
+      && strverscmp (darwin_macosx_version_min, "10.5") < 0)
+    darwin_emit_branch_islands = true;
 }
 
 /* Add $LDBL128 suffix to long double builtins.  */
index 7a073742cb634752b683a2dcf2fe24f3d356dbd2..f1527105dee13ec7e2d02cb5dfe4bf2052f217b2 100644 (file)
@@ -44,9 +44,6 @@ along with GCC; see the file COPYING3.  If not see
 /* libSystem contains unwind information for signal frames.  */
 #define DARWIN_LIBSYSTEM_HAS_UNWIND
 
-/* The linker can generate branch islands.  */
-#define DARWIN_LINKER_GENERATES_ISLANDS 1
-
 #undef  ASM_OUTPUT_ALIGNED_COMMON
 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)             \
   do {                                                                 \
index d26ef2d422ddb45930bc42d998b2652acb542da7..7917f2fc18fe9a45d012213c5a59e2b5e4c1ece5 100644 (file)
@@ -60,6 +60,12 @@ 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 TARGET_MACHO_BRANCH_ISLANDS
+#define TARGET_MACHO_BRANCH_ISLANDS darwin_emit_branch_islands
+
 #undef MAX_BITS_PER_WORD
 #define MAX_BITS_PER_WORD 64
 
@@ -225,7 +231,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 (TARGET_MACHO_BRANCH_ISLANDS && MACHOPIC_INDIRECT && !TARGET_64BIT)           \
        {                                                               \
          const char *name = machopic_mcount_stub_name ();              \
          fprintf (FILE, "\tcall %s\n", name+1);  /*  skip '&'  */      \
index fdb4787c94f70ad4a53c8ad9af9a655acf112df3..bb0b890277f3603c22e460d680912b245574de55 100644 (file)
@@ -11513,7 +11513,7 @@ output_pic_addr_const (FILE *file, rtx x, int code)
       break;
 
     case SYMBOL_REF:
-      if (! TARGET_MACHO || TARGET_64BIT)
+      if (TARGET_64BIT || ! TARGET_MACHO_BRANCH_ISLANDS)
        output_addr_const (file, x);
       else
        {
@@ -27233,10 +27233,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 b5c6b9ae2f9f7411e53c94bacd35198719263d5a..e153920a5c1b7f16969b25eeecbababd0c778ad3 100644 (file)
@@ -477,7 +477,13 @@ extern tree x86_mfence;
    redefines this to 1.  */
 #define TARGET_MACHO 0
 
-/* Likewise, for the Windows 64-bit ABI.  */
+/* Branch island 'stubs' are emitted for earlier versions of darwin.
+   This provides a default (over-ridden in darwin.h.)  */
+#ifndef TARGET_MACHO_BRANCH_ISLANDS
+#define TARGET_MACHO_BRANCH_ISLANDS 0
+#endif
+
+/* For the Windows 64-bit ABI.  */
 #define TARGET_64BIT_MS_ABI (TARGET_64BIT && ix86_cfun_abi () == MS_ABI)
 
 /* Available call abi.  */
index 98d44cfbde55dcdc01c3318d82baa3f0583c49e7..810563e0ed0cc603e9134e7c8cc592ae6c27f37b 100644 (file)
@@ -65,6 +65,9 @@
     }                                                  \
   while (0)
 
+/* Generate branch islands stubs if this is true.  */
+extern int darwin_emit_branch_islands;
+
 #define SUBTARGET_OVERRIDE_OPTIONS darwin_rs6000_override_options ()
 
 #define C_COMMON_OVERRIDE_OPTIONS do {                                 \
 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
   (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
 
-/* XXX: Darwin supports neither .quad, or .llong, but it also doesn't
-   support 64 bit PowerPC either, so this just keeps things happy.  */
 #define DOUBLE_INT_ASM_OP "\t.quad\t"
 
 /* For binary compatibility with 2.95; Darwin C APIs use bool from
index d96c1d6f32df99c1457562039c5d4a0639077c1f..3a8c70760033829a5b8272ec3fb90c7f4b2a30c0 100644 (file)
@@ -15392,7 +15392,8 @@ print_operand (FILE *file, rtx x, int code)
        {
          const char *name = XSTR (x, 0);
 #if TARGET_MACHO
-         if (MACHOPIC_INDIRECT
+         if (darwin_emit_branch_islands
+             && MACHOPIC_INDIRECT
              && machopic_classify_symbol (x) == MACHOPIC_UNDEFINED_FUNCTION)
            name = machopic_indirection_name (x, /*stub_p=*/true);
 #endif
@@ -24482,14 +24483,6 @@ get_prev_label (tree function_name)
   return 0;
 }
 
-#ifndef DARWIN_LINKER_GENERATES_ISLANDS
-#define DARWIN_LINKER_GENERATES_ISLANDS 0
-#endif
-
-/* KEXTs still need branch islands.  */
-#define DARWIN_GENERATE_ISLANDS (!DARWIN_LINKER_GENERATES_ISLANDS \
-                                || flag_mkernel || flag_apple_kext)
-
 /* INSN is either a function call or a millicode call.  It may have an
    unconditional jump in its delay slot.
 
@@ -24500,7 +24493,7 @@ output_call (rtx insn, rtx *operands, int dest_operand_number,
             int cookie_operand_number)
 {
   static char buf[256];
-  if (DARWIN_GENERATE_ISLANDS
+  if (darwin_emit_branch_islands
       && GET_CODE (operands[dest_operand_number]) == SYMBOL_REF
       && (INTVAL (operands[cookie_operand_number]) & CALL_LONG))
     {