[ARC] Add support for profiling in glibc.
authorClaudiu Zissulescu <claziss@synopsys.com>
Tue, 13 Nov 2018 12:51:41 +0000 (13:51 +0100)
committerClaudiu Zissulescu <claziss@gcc.gnu.org>
Tue, 13 Nov 2018 12:51:41 +0000 (13:51 +0100)
Use PROFILE_HOOK to add mcount library calls in each toolchain.

gcc/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

* config/arc/arc.h (FUNCTION_PROFILER): Redefine to empty.
* config/arc/elf.h (PROFILE_HOOK): Define.
* config/arc/linux.h (PROFILE_HOOK): Likewise.

From-SVN: r266068

gcc/ChangeLog
gcc/config/arc/arc.h
gcc/config/arc/elf.h
gcc/config/arc/linux.h

index 7ba3fd3f359e063da20e78ecac36cf1c1daa28ca..3f94aeb8080a2508e7dc623a3135d82fb6cba2ba 100644 (file)
@@ -1,3 +1,9 @@
+2018-11-13  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * config/arc/arc.h (FUNCTION_PROFILER): Redefine to empty.
+       * config/arc/elf.h (PROFILE_HOOK): Define.
+       * config/arc/linux.h (PROFILE_HOOK): Likewise.
+
 2018-11-13  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * config/arc/arc.c (hwloop_optimize): Bailout when detecting a
index 6e9b1e5ddb61a4fa9c746e211d8860dc95f5a8e4..b81b0e7ba33d3c48028bd96164d631b56e80b529 100644 (file)
@@ -811,15 +811,9 @@ extern int arc_initial_elimination_offset(int from, int to);
 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                    \
   (OFFSET) = arc_initial_elimination_offset ((FROM), (TO))
 
-/* Output assembler code to FILE to increment profiler label # LABELNO
-   for profiling a function entry.  */
-#define FUNCTION_PROFILER(FILE, LABELNO)                       \
-  do {                                                         \
-  if (flag_pic)                                                        \
-    fprintf (FILE, "\tbl\t__mcount@plt\n");                    \
-  else                                                         \
-    fprintf (FILE, "\tbl\t__mcount\n");                                \
-  } while (0)
+/* All the work done in PROFILE_HOOK, but still required.  */
+#undef FUNCTION_PROFILER
+#define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0)
 
 #define NO_PROFILE_COUNTERS  1
 
index 3472fd2e4188f2b81b642f39157c4218a5b0b731..3aabcf8c9e64896803a5ffa213750aacd8df6507 100644 (file)
@@ -78,3 +78,12 @@ along with GCC; see the file COPYING3.  If not see
 #undef LINK_GCC_C_SEQUENCE_SPEC
 #define LINK_GCC_C_SEQUENCE_SPEC                               \
   "--start-group %G %{!specs=*:%{!nolibc:-lc -lnosys}} --end-group"
+
+/* Emit rtl for profiling.  Output assembler code to FILE
+   to call "_mcount" for profiling a function entry.  */
+#define PROFILE_HOOK(LABEL)                                    \
+  {                                                            \
+    rtx fun;                                                   \
+    fun = gen_rtx_SYMBOL_REF (Pmode, "__mcount");              \
+    emit_library_call (fun, LCT_NORMAL, VOIDmode);             \
+  }
index 62ebe4de0fc75b894a325d8395f6f8e0aada4bc3..993f445d2a0ad0451ad1dae0f613d4b8c9e5abfd 100644 (file)
@@ -123,3 +123,13 @@ along with GCC; see the file COPYING3.  If not see
                    : "=r" (_beg)                                       \
                    : "0" (_beg), "r" (_end), "r" (_xtr), "r" (_scno)); \
 }
+
+/* Emit rtl for profiling.  Output assembler code to FILE
+   to call "_mcount" for profiling a function entry.  */
+#define PROFILE_HOOK(LABEL)                                    \
+  {                                                            \
+   rtx fun, rt;                                                        \
+   rt = get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM);  \
+   fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount");                        \
+   emit_library_call (fun, LCT_NORMAL, VOIDmode, rt, Pmode);   \
+  }