From b482789cca42c2e1c3d0c7dd1c140fe3e5e320a2 Mon Sep 17 00:00:00 2001 From: Matt Austern Date: Mon, 20 Dec 2004 20:11:41 +0000 Subject: [PATCH] re PR c++/19044 (Alternate asm name for atan ignored when calling __builtin_atan) 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 | 7 +++++++ gcc/c-common.c | 20 ++++++++++++++++++++ gcc/c-common.h | 2 ++ gcc/c-decl.c | 9 +-------- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 7 ++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/builtin6.C | 11 +++++++++++ 8 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/builtin6.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 08bceddaf7f..db153d504ed 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2004-12-20 Matt Austern + + 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 PR tree-optimization/19080 diff --git a/gcc/c-common.c b/gcc/c-common.c index bf48029fd49..b4c6349cbd8 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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) { diff --git a/gcc/c-common.h b/gcc/c-common.h index d0fbaa837df..8ebc560169f 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -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); diff --git a/gcc/c-decl.c b/gcc/c-decl.c index e6b4cba7912..97420d16cc2 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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); } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 57affb008c2..ac2a9abb684 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2004-12-20 Matt Austern + + PR c++/19044 + * decl.c (make_rtl_for_nonlocal_decl): Use set_builtin_user_assembler_name + 2004-12-19 Mark Mitchell * cp-tree.h (note_decl_for_pch): New function. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 01a3312bfb8..dbaf23e23c2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5dfec5c4f3c..19bbb9ad0d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-12-20 Matt Austern + + PR c++/19044 + * g++.dg/ext/builtin6.C: New + 2004-12-20 Diego Novillo 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 index 00000000000..8f405b095c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin6.C @@ -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); } + -- 2.30.2