]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR other/42333 (complex division failure on darwin10 with -lm)
authorJack Howarth <howarth@bromo.med.uc.edu>
Thu, 30 Jun 2011 16:31:23 +0000 (16:31 +0000)
committerMike Stump <mrs@gcc.gnu.org>
Thu, 30 Jun 2011 16:31:23 +0000 (16:31 +0000)
2011-06-30  Jack Howarth  <howarth@bromo.med.uc.edu>

        Backport from mainline
        2011-02-07 Mike Stump  <mikestump@comcast.net>

        PR target/42333
        Add __ieee_divdc3 entry point.
        * config/i386/darwin.h (DECLARE_LIBRARY_RENAMES): Retain ___divdc3
        entry point.
        (SUBTARGET_INIT_BUILTINS): Call darwin_rename_builtins.
        * config/i386/i386.c (TARGET_INIT_LIBFUNCS): Likewise.
        * config/darwin.c (darwin_rename_builtins): Add.
        * config/darwin-protos.h (darwin_rename_builtins): Add.

From-SVN: r175711

gcc/ChangeLog
gcc/config/darwin-protos.h
gcc/config/darwin.c
gcc/config/i386/darwin.h
gcc/config/i386/i386.c

index e21f3750672ebd8edc3cd7999bbecdcd495643c6..37eba05b9e8761500a8816f378516066ad398a1d 100644 (file)
@@ -1,3 +1,17 @@
+2011-06-30  Jack Howarth  <howarth@bromo.med.uc.edu>
+
+        Backport from mainline
+        2011-02-07 Mike Stump  <mikestump@comcast.net>
+
+        PR target/42333
+        Add __ieee_divdc3 entry point.
+        * config/i386/darwin.h (DECLARE_LIBRARY_RENAMES): Retain ___divdc3
+        entry point.
+        (SUBTARGET_INIT_BUILTINS): Call darwin_rename_builtins.
+        * config/i386/i386.c (TARGET_INIT_LIBFUNCS): Likewise.
+        * config/darwin.c (darwin_rename_builtins): Add.
+        * config/darwin-protos.h (darwin_rename_builtins): Add.
+
 2011-06-28  Eric Botcazou  <ebotcazou@adacore.com>
 
        * tree-ssa-dom.c (initialize_hash_element): Fix oversight.
index 5886f0158a6e2b38a12973575518b12221861820..b860536138f0e76835379d1e6a7838cae2193bce 100644 (file)
@@ -93,3 +93,4 @@ extern void darwin_asm_output_anchor (rtx symbol);
 extern bool darwin_kextabi_p (void);
 extern void darwin_override_options (void);
 extern void darwin_patch_builtins (void);
+extern void darwin_rename_builtins (void);
index 81ee8c72f45ce9e5c523c0eea363bd3721926d26..31557cb13bc7aa3488b781ea2e0588aa4dc72ef7 100644 (file)
@@ -337,6 +337,34 @@ static GTY ((param_is (struct machopic_indirection))) htab_t
 
 /* Return a hash value for a SLOT in the indirections hash table.  */
 
+void
+darwin_rename_builtins (void)
+{
+  /* The system ___divdc3 routine in libSystem on darwin10 is not
+     accurate to 1ulp, ours is, so we avoid ever using the system name
+     for this routine and instead install a non-conflicting name that
+     is accurate.
+
+     When -ffast-math or -funsafe-math-optimizations is given, we can
+     use the faster version.  */
+  if (!flag_unsafe_math_optimizations)
+    {
+      int dcode = (BUILT_IN_COMPLEX_DIV_MIN
+                  + DCmode - MIN_MODE_COMPLEX_FLOAT);
+      tree fn = built_in_decls[dcode];
+      /* Fortran and c call TARGET_INIT_BUILTINS and
+        TARGET_INIT_LIBFUNCS at different times, so we have to put a
+        call into each to ensure that at least one of them is called
+        after build_common_builtin_nodes.  A better fix is to add a
+        new hook to run after build_common_builtin_nodes runs.  */
+      if (fn)
+       set_user_assembler_name (fn, "___ieee_divdc3");
+      fn = implicit_built_in_decls[dcode];
+      if (fn)
+       set_user_assembler_name (fn, "___ieee_divdc3");
+    }
+}
+
 static hashval_t
 machopic_indirection_hash (const void *slot)
 {
index 5bd9571bde0e883b0f339a0a5797fa27bc1b8e94..6b40c997d4339afc46e85e6066da7481b0f9e5ac 100644 (file)
@@ -302,3 +302,17 @@ 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"
+
+#define SUBTARGET_INIT_BUILTINS                                        \
+do {                                                           \
+  darwin_rename_builtins ();                                   \
+} while(0)
+/* The system ___divdc3 routine in libSystem on darwin10 is not
+   accurate to 1ulp, ours is, so we avoid ever using the system name
+   for this routine and instead install a non-conflicting name that is
+   accurate.  See darwin_rename_builtins.  */
+#ifdef L_divdc3
+#define DECLARE_LIBRARY_RENAMES \
+  asm(".text; ___divdc3: jmp ___ieee_divdc3 ; .globl ___divdc3");
+#endif
index 35e1ceeeddc59789144b9a864ccbddb6f3a0dfa7..14775796b732b31b3a4866c0595ca30a3bda42e3 100644 (file)
@@ -30665,6 +30665,11 @@ ix86_enum_va_list (int idx, const char **pname, tree *ptree)
 #undef TARGET_ASM_CODE_END
 #define TARGET_ASM_CODE_END ix86_code_end
 
+#if TARGET_MACHO
+#undef TARGET_INIT_LIBFUNCS
+#define TARGET_INIT_LIBFUNCS darwin_rename_builtins
+#endif
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 #include "gt-i386.h"