OSDN Git Service

* tree.c (build_common_builtin_nodes): Do not initialize
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Dec 2010 16:45:36 +0000 (16:45 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Dec 2010 16:45:36 +0000 (16:45 +0000)
BUILT_IN_PROFILE_FUNC_ENTER and BUILT_IN_PROFILE_FUNC_EXIT.
* builtins.c (expand_builtin_profile_func): Remove.
(expand_builtin): Do not handle BUILT_IN_PROFILE_FUNC_ENTER and
BUILT_IN_PROFILE_FUNC_EXIT.
* builtins.def (profile_func_enter, profile_func_exit): Remove stubs.
(__cyg_profile_func_enter, __cyg_profile_func_exit): New.
* gimplify.c (gimplify_function_tree): Reorganize code calling
profiling functions.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167342 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c
gcc/builtins.def
gcc/gimplify.c
gcc/tree.c

index bdfc8a2..26c6e8e 100644 (file)
@@ -1,3 +1,15 @@
+2010-12-01  Jan Hubicka  <jh@suse.cz>
+
+       * tree.c (build_common_builtin_nodes): Do not initialize
+       BUILT_IN_PROFILE_FUNC_ENTER and BUILT_IN_PROFILE_FUNC_EXIT.
+       * builtins.c (expand_builtin_profile_func): Remove.
+       (expand_builtin): Do not handle BUILT_IN_PROFILE_FUNC_ENTER and
+       BUILT_IN_PROFILE_FUNC_EXIT.
+       * builtins.def (profile_func_enter, profile_func_exit): Remove stubs.
+       (__cyg_profile_func_enter, __cyg_profile_func_exit): New.
+       * gimplify.c (gimplify_function_tree): Reorganize code calling
+       profiling functions.
+
 2010-12-01  Joseph Myers  <joseph@codesourcery.com>
 
        * opts.c: Expand comment on tm.h include.
index 5c09382..2816a7e 100644 (file)
@@ -5202,30 +5202,6 @@ build_string_literal (int len, const char *str)
   return t;
 }
 
-/* Expand a call to either the entry or exit function profiler.  */
-
-static rtx
-expand_builtin_profile_func (bool exitp)
-{
-  rtx this_rtx, which;
-
-  this_rtx = DECL_RTL (current_function_decl);
-  gcc_assert (MEM_P (this_rtx));
-  this_rtx = XEXP (this_rtx, 0);
-
-  if (exitp)
-    which = profile_function_exit_libfunc;
-  else
-    which = profile_function_entry_libfunc;
-
-  emit_library_call (which, LCT_NORMAL, VOIDmode, 2, this_rtx, Pmode,
-                    expand_builtin_return_addr (BUILT_IN_RETURN_ADDRESS,
-                                                0),
-                    Pmode);
-
-  return const0_rtx;
-}
-
 /* Expand a call to __builtin___clear_cache.  */
 
 static rtx
@@ -6364,11 +6340,6 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
       expand_builtin_prefetch (exp);
       return const0_rtx;
 
-    case BUILT_IN_PROFILE_FUNC_ENTER:
-      return expand_builtin_profile_func (false);
-    case BUILT_IN_PROFILE_FUNC_EXIT:
-      return expand_builtin_profile_func (true);
-
     case BUILT_IN_INIT_TRAMPOLINE:
       return expand_builtin_init_trampoline (exp);
     case BUILT_IN_ADJUST_TRAMPOLINE:
index 28bcc0b..3e102e3 100644 (file)
@@ -743,8 +743,10 @@ DEF_EXT_LIB_BUILTIN    (BUILT_IN_VFPRINTF_CHK, "__vfprintf_chk", BT_FN_INT_FILEP
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_VPRINTF_CHK, "__vprintf_chk", BT_FN_INT_INT_CONST_STRING_VALIST_ARG, ATTR_FORMAT_PRINTF_2_0)
 
 /* Profiling hooks.  */
-DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter")
-DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit")
+DEF_BUILTIN (BUILT_IN_PROFILE_FUNC_ENTER, "__cyg_profile_func_enter", BUILT_IN_NORMAL, BT_FN_VOID_PTR_PTR, BT_LAST,
+            false, false, false, ATTR_NULL, true, true)
+DEF_BUILTIN (BUILT_IN_PROFILE_FUNC_EXIT, "__cyg_profile_func_exit", BUILT_IN_NORMAL, BT_FN_VOID_PTR_PTR, BT_LAST,
+            false, false, false, ATTR_NULL, true, true)
 
 /* TLS emulation.  */
 DEF_BUILTIN (BUILT_IN_EMUTLS_GET_ADDRESS, targetm.emutls.get_address,
index 59e4248..10e2b24 100644 (file)
@@ -7861,13 +7861,31 @@ gimplify_function_tree (tree fndecl)
       gimple new_bind;
       gimple tf;
       gimple_seq cleanup = NULL, body = NULL;
-
+      tree tmp_var;
+      gimple call;
+
+      x = implicit_built_in_decls[BUILT_IN_RETURN_ADDRESS];
+      call = gimple_build_call (x, 0);
+      tmp_var = create_tmp_var (ptr_type_node, "return_addr");
+      gimple_call_set_lhs (call, tmp_var);
+      gimplify_seq_add_stmt (&cleanup, call);
       x = implicit_built_in_decls[BUILT_IN_PROFILE_FUNC_EXIT];
-      gimplify_seq_add_stmt (&cleanup, gimple_build_call (x, 0));
+      call = gimple_build_call (x, 2,
+                               build_fold_addr_expr (current_function_decl),
+                               tmp_var);
+      gimplify_seq_add_stmt (&cleanup, call);
       tf = gimple_build_try (seq, cleanup, GIMPLE_TRY_FINALLY);
 
+      x = implicit_built_in_decls[BUILT_IN_RETURN_ADDRESS];
+      call = gimple_build_call (x, 0);
+      tmp_var = create_tmp_var (ptr_type_node, "return_addr");
+      gimple_call_set_lhs (call, tmp_var);
+      gimplify_seq_add_stmt (&body, call);
       x = implicit_built_in_decls[BUILT_IN_PROFILE_FUNC_ENTER];
-      gimplify_seq_add_stmt (&body, gimple_build_call (x, 0));
+      call = gimple_build_call (x, 2,
+                               build_fold_addr_expr (current_function_decl),
+                               tmp_var);
+      gimplify_seq_add_stmt (&body, call);
       gimplify_seq_add_stmt (&body, tf);
       new_bind = gimple_build_bind (NULL, body, gimple_bind_block (bind));
       /* Clear the block for BIND, since it is no longer directly inside
index 88666d3..3a41244 100644 (file)
@@ -9324,12 +9324,6 @@ build_common_builtin_nodes (void)
                        BUILT_IN_STACK_RESTORE,
                        "__builtin_stack_restore", ECF_NOTHROW | ECF_LEAF);
 
-  ftype = build_function_type_list (void_type_node, NULL_TREE);
-  local_define_builtin ("__builtin_profile_func_enter", ftype,
-                       BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter", 0);
-  local_define_builtin ("__builtin_profile_func_exit", ftype,
-                       BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 0);
-
   /* If there's a possibility that we might use the ARM EABI, build the
     alternate __cxa_end_cleanup node used to resume from C++ and Java.  */
   if (targetm.arm_eabi_unwinder)