public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC Patch, Aarch64] : Macros for profile code generation to enable gprof support
@ 2013-08-03 18:01 Venkataramanan Kumar
  2013-08-09 10:48 ` Venkataramanan Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Venkataramanan Kumar @ 2013-08-03 18:01 UTC (permalink / raw)
  To: gcc-patches, Marcus Shawcroft, Andrew Pinski, Marcus Shawcroft,
	Richard Earnshaw

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

Hi Maintainers,

This patch adds macros to support gprof in Aarch64. The difference
from the previous patch is that the compiler, while generating
"mcount" routine for an instrumented function, also passes the return
address as argument.

The "mcount" routine in glibc will be modified as follows.

(-----Snip-----)
 #define MCOUNT \
-void __mcount (void)                                                         \
+void __mcount (void* frompc)
               \
 {                                                                            \
-  mcount_internal ((u_long) RETURN_ADDRESS (1), (u_long) RETURN_ADDRESS (0)); \
+  mcount_internal ((u_long) frompc, (u_long) RETURN_ADDRESS (0)); \
 }
(-----Snip-----)

Also in Aarch64 cases__builtin_return_adderess(n) where n>0, still be
returning 0 as it was doing before.

If this is Ok I will send the patch to glibc as well.

2013-08-02  Venkataramanan Kumar  <venkataramanan.kumar@linaro.org>

         * config/aarch64/aarch64.h (MCOUNT_NAME): Define.
           (NO_PROFILE_COUNTERS): Likewise.
           (PROFILE_HOOK): Likewise.
           (FUNCTION_PROFILER): Likewise.
        *  config/aarch64/aarch64.c (aarch64_function_profiler): Remove.
           .

regards,
Venkat.

[-- Attachment #2: gcc.gprof.diff --]
[-- Type: application/octet-stream, Size: 2237 bytes --]

Index: gcc/config/aarch64/aarch64.c
===================================================================
--- gcc/config/aarch64/aarch64.c	(revision 201441)
+++ gcc/config/aarch64/aarch64.c	(working copy)
@@ -3856,13 +3856,6 @@
   output_addr_const (f, x);
 }
 
-void
-aarch64_function_profiler (FILE *f ATTRIBUTE_UNUSED,
-			   int labelno ATTRIBUTE_UNUSED)
-{
-  sorry ("function profiling");
-}
-
 bool
 aarch64_label_mentioned_p (rtx x)
 {
Index: gcc/config/aarch64/aarch64.h
===================================================================
--- gcc/config/aarch64/aarch64.h	(revision 201441)
+++ gcc/config/aarch64/aarch64.h	(working copy)
@@ -781,9 +781,23 @@
 #define PRINT_OPERAND_ADDRESS(STREAM, X) \
   aarch64_print_operand_address (STREAM, X)
 
-#define FUNCTION_PROFILER(STREAM, LABELNO) \
-  aarch64_function_profiler (STREAM, LABELNO)
+#define MCOUNT_NAME "_mcount"
 
+#define NO_PROFILE_COUNTERS 1
+
+/* Emit rtl for profiling.  Output assembler code to FILE
+   to call "_mcount" for profiling a function entry.  */
+#define PROFILE_HOOK(LABEL)                                  \
+{                                                            \
+  rtx fun,lr;                                                \
+  lr = get_hard_reg_initial_val (Pmode, LR_REGNUM);          \
+  fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_NAME);             \
+  emit_library_call (fun, LCT_NORMAL, VOIDmode, 1,lr,Pmode); \
+}
+
+/* All the work done in PROFILE_HOOK, but still required.  */
+#define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0)
+
 /* For some reason, the Linux headers think they know how to define
    these macros.  They don't!!!  */
 #undef ASM_APP_ON
Index: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp	(revision 201441)
+++ gcc/testsuite/lib/target-supports.exp	(working copy)
@@ -487,13 +487,6 @@
 	return 0
     }
 
-    # We don't yet support profiling for AArch64.
-    if { [istarget aarch64*-*-*]
-	 && ([lindex $test_what 1] == "-p"
-	     || [lindex $test_what 1] == "-pg") } {
-	return 0
-    }
-
     # cygwin does not support -p.
     if { [istarget *-*-cygwin*] && $test_what == "-p" } {
 	return 0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-09-30  8:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-03 18:01 [RFC Patch, Aarch64] : Macros for profile code generation to enable gprof support Venkataramanan Kumar
2013-08-09 10:48 ` Venkataramanan Kumar
2013-08-09 17:17 ` Marcus Shawcroft
2013-08-12 13:08   ` Matthew Gretton-Dann
2013-08-27  7:46 ` Marcus Shawcroft
2013-09-28 13:41   ` Venkataramanan Kumar
2013-09-30  9:34     ` Marcus Shawcroft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).