Improve entry/exit instrumentation for nested functions
authorOlivier Hainque <hainque@adacore.com>
Fri, 22 Jun 2018 16:46:22 +0000 (16:46 +0000)
committerOlivier Hainque <hainque@gcc.gnu.org>
Fri, 22 Jun 2018 16:46:22 +0000 (16:46 +0000)
2018-06-22  Olivier Hainque  <hainque@adacore.com>

* gimplify.c (gimplify_function_tree): Prevent creation
of a trampoline for the address of the current function
passed to entry/exit instrumentation hooks.

From-SVN: r261908

gcc/ChangeLog
gcc/gimplify.c

index 22d751f02d3a36f719450fb20a89eed0d631da4e..4b14a342af1e09a83f5aed3e4a3d3d544180a8e6 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-22  Olivier Hainque  <hainque@adacore.com>
+
+       * gimplify.c (gimplify_function_tree): Prevent creation
+       of a trampoline for the address of the current function
+       passed to entry/exit instrumentation hooks.
+
 2018-06-22  Aaron Sawdey  <acsawdey@linux.ibm.com>
 
        PR target/86222
index 97543ed5f705d83c58a4489dddf8826a262b7274..48ac92e2b16dabda6d2dd93a870111b021369aa5 100644 (file)
@@ -12799,18 +12799,23 @@ gimplify_function_tree (tree fndecl)
       gbind *new_bind;
       gimple *tf;
       gimple_seq cleanup = NULL, body = NULL;
-      tree tmp_var;
+      tree tmp_var, this_fn_addr;
       gcall *call;
 
+      /* The instrumentation hooks aren't going to call the instrumented
+        function and the address they receive is expected to be matchable
+        against symbol addresses.  Make sure we don't create a trampoline,
+        in case the current function is nested.  */
+      this_fn_addr = build_fold_addr_expr (current_function_decl);
+      TREE_NO_TRAMPOLINE (this_fn_addr) = 1;
+
       x = builtin_decl_implicit (BUILT_IN_RETURN_ADDRESS);
       call = gimple_build_call (x, 1, integer_zero_node);
       tmp_var = create_tmp_var (ptr_type_node, "return_addr");
       gimple_call_set_lhs (call, tmp_var);
       gimplify_seq_add_stmt (&cleanup, call);
       x = builtin_decl_implicit (BUILT_IN_PROFILE_FUNC_EXIT);
-      call = gimple_build_call (x, 2,
-                               build_fold_addr_expr (current_function_decl),
-                               tmp_var);
+      call = gimple_build_call (x, 2, this_fn_addr, tmp_var);
       gimplify_seq_add_stmt (&cleanup, call);
       tf = gimple_build_try (seq, cleanup, GIMPLE_TRY_FINALLY);
 
@@ -12820,9 +12825,7 @@ gimplify_function_tree (tree fndecl)
       gimple_call_set_lhs (call, tmp_var);
       gimplify_seq_add_stmt (&body, call);
       x = builtin_decl_implicit (BUILT_IN_PROFILE_FUNC_ENTER);
-      call = gimple_build_call (x, 2,
-                               build_fold_addr_expr (current_function_decl),
-                               tmp_var);
+      call = gimple_build_call (x, 2, this_fn_addr, tmp_var);
       gimplify_seq_add_stmt (&body, call);
       gimplify_seq_add_stmt (&body, tf);
       new_bind = gimple_build_bind (NULL, body, NULL);