re PR c++/19044 (Alternate asm name for atan ignored when calling __builtin_atan)
authorMatt Austern <austern@apple.com>
Mon, 20 Dec 2004 20:11:41 +0000 (20:11 +0000)
committerMatt Austern <austern@gcc.gnu.org>
Mon, 20 Dec 2004 20:11:41 +0000 (20:11 +0000)
PR c++/19044

* c-common.c (set_builtin_user_assembler_name): New.
* c-common.h (set_builtin_user_assembler_name): Declare.
* c-decl.c (finish_decl): Use set_builtin_user_assembler_name

* decl.c (make_rtl_for_nonlocal_decl): Use set_builtin_user_assembler_name

* g++.dg/ext/builtin6.C: New

From-SVN: r92428

gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/builtin6.C [new file with mode: 0644]

index 08bceddaf7f35735839f950d9a9cd18bd5955b48..db153d504ed2c297073d01187b183868ebcbc47b 100644 (file)
@@ -1,3 +1,10 @@
+2004-12-20  Matt Austern  <austern@apple.com>
+
+       PR c++/19044
+       * c-common.c (set_builtin_user_assembler_name): New.
+       * c-common.h (set_builtin_user_assembler_name): Declare.
+       * c-decl.c (finish_decl): Use set_builtin_user_assembler_name
+       
 2004-12-20  Diego Novillo  <dnovillo@redhat.com>
 
        PR tree-optimization/19080
index bf48029fd497767220078ab2787db3314070385f..b4c6349cbd83009e1e1267c1efcdd1bb08fb4724 100644 (file)
@@ -3223,6 +3223,26 @@ c_common_nodes_and_builtins (void)
   main_identifier_node = get_identifier ("main");
 }
 
+/* Look up the function in built_in_decls that corresponds to DECL
+   and set ASMSPEC as its user assembler name.  DECL must be a
+   function decl that declares a builtin. */
+
+void
+set_builtin_user_assembler_name (tree decl, const char *asmspec)
+{
+  tree builtin;
+  gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
+             && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
+             && asmspec != 0);
+
+  builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
+  set_user_assembler_name (builtin, asmspec);
+  if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
+    init_block_move_fn (asmspec);
+  else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
+    init_block_clear_fn (asmspec);
+}
+
 tree
 build_va_arg (tree expr, tree type)
 {
index d0fbaa837dfdedbb2d3c3ee73a6772e4877eb4a9..8ebc560169f08483547cf6987a3368727b15c7bf 100644 (file)
@@ -674,6 +674,8 @@ extern tree c_build_qualified_type (tree, int);
    frontends.  */
 extern void c_common_nodes_and_builtins (void);
 
+extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
+
 extern void disable_builtin_function (const char *);
 
 extern tree build_va_arg (tree, tree);
index e6b4cba791294418f96c2b4bc86ebd380a41deb0..97420d16cc2a544acda9967d608730af7d1d0a7a 100644 (file)
@@ -3233,14 +3233,7 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
   if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
     {
       if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
-       {
-         tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
-         set_user_assembler_name (builtin, asmspec);
-          if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
-            init_block_move_fn (asmspec);
-          else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
-            init_block_clear_fn (asmspec);
-        }
+       set_builtin_user_assembler_name (decl, asmspec);
       set_user_assembler_name (decl, asmspec);
     }
 
index 57affb008c273d398515fce0ff811ac14022ccb7..ac2a9abb684406bda66f5400bdc2f49f9949e7eb 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-20  Matt Austern <austern@apple.com>
+
+       PR c++/19044
+       * decl.c (make_rtl_for_nonlocal_decl): Use set_builtin_user_assembler_name
+       
 2004-12-19  Mark Mitchell  <mark@codesourcery.com>
 
        * cp-tree.h (note_decl_for_pch): New function.
index 01a3312bfb8b96e293782831bb9371cc3f316691..dbaf23e23c2614d0167883678a31fa1e3b825a6d 100644 (file)
@@ -4644,7 +4644,12 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec)
          DECL_HARD_REGISTER (decl) = 1;
        }
       else
-       set_user_assembler_name (decl, asmspec);
+       {
+         if (TREE_CODE (decl) == FUNCTION_DECL
+             && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+           set_builtin_user_assembler_name (decl, asmspec);
+         set_user_assembler_name (decl, asmspec);
+       }
     }
 
   /* Handle non-variables up front.  */
index 5dfec5c4f3c4cc5e6958296299e8e348387661eb..19bbb9ad0d37361d4c5230b428343178846b144e 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-20  Matt Austern  <austern@apple.com>
+
+       PR c++/19044
+       * g++.dg/ext/builtin6.C: New
+       
 2004-12-20  Diego Novillo  <dnovillo@redhat.com>
 
        PR tree-optimization/19080
diff --git a/gcc/testsuite/g++.dg/ext/builtin6.C b/gcc/testsuite/g++.dg/ext/builtin6.C
new file mode 100644 (file)
index 0000000..8f405b0
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/19044
+// Verify that alternate asm name for builtin named "foo" also gets
+// applied to its sibling "__builtin_foo".
+
+// { dg-do compile }
+// { dg-final { scan-assembler "fancy_sin" } }
+
+extern "C" double sin(double) __asm("_fancy_sin");
+
+double foo(double x) { return __builtin_sin(x); }
+