Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Fix userland gprof profiling on aarch64.



details:   https://anonhg.NetBSD.org/src/rev/5a945ac8882e
branches:  trunk
changeset: 1009467:5a945ac8882e
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Thu Apr 23 23:22:41 2020 +0000

description:
Fix userland gprof profiling on aarch64.

Adjusts _PROF_PROLOGUE to match OpenBSD; reworks our MCOUNT to retrieve
frompc placed on stack by the prologue, and to streamline sp manipulation
when preserving argument registers.

diffstat:

 sys/arch/aarch64/include/profile.h |  27 ++++++++++++---------------
 sys/arch/arm/include/asm.h         |   7 +++++--
 2 files changed, 17 insertions(+), 17 deletions(-)

diffs (75 lines):

diff -r 4037d6b95d64 -r 5a945ac8882e sys/arch/aarch64/include/profile.h
--- a/sys/arch/aarch64/include/profile.h        Thu Apr 23 22:58:36 2020 +0000
+++ b/sys/arch/aarch64/include/profile.h        Thu Apr 23 23:22:41 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: profile.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
+/* $NetBSD: profile.h,v 1.2 2020/04/23 23:22:41 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -51,20 +51,18 @@
        /*                                                              \
         * Preserve registers that are trashed during mcount            \
         */                                                             \
-       __asm("sub      sp, sp, #80");                                  \
-       __asm("stp      x29, x30, [sp, #64]");                          \
-       __asm("add      x29, sp, #64");                                 \
-       __asm("stp      x0, x1, [x29, #0]");                            \
-       __asm("stp      x2, x3, [x29, #16]");                           \
-       __asm("stp      x4, x5, [x29, #32]");                           \
-       __asm("stp      x6, x7, [x29, #48]");                           \
+       __asm("stp      x29, x30, [sp, #-80]!");                        \
+       __asm("stp      x0, x1, [sp, #16]");                            \
+       __asm("stp      x2, x3, [sp, #32]");                            \
+       __asm("stp      x4, x5, [sp, #48]");                            \
+       __asm("stp      x6, x7, [sp, #64]");                            \
        /*                                                              \
         * find the return address for mcount,                          \
         * and the return address for mcount's caller.                  \
         *                                                              \
         * frompcindex = pc pushed by call into self.                   \
         */                                                             \
-       __asm("mov      x0, x19");                                      \
+       __asm("ldr      x0, [x29, #8]");                                \
        /*                                                              \
         * selfpc = pc pushed by mcount call                            \
         */                                                             \
@@ -76,12 +74,11 @@
        /*                                                              \
         * Restore registers that were trashed during mcount            \
         */                                                             \
-       __asm("ldp      x0, x1, [x29, #0]");                            \
-       __asm("ldp      x2, x3, [x29, #16]");                           \
-       __asm("ldp      x4, x5, [x29, #32]");                           \
-       __asm("ldp      x6, x7, [x29, #48]");                           \
-       __asm("ldp      x29, x30, [x29, #64]");                         \
-       __asm("add      sp, sp, #80");                                  \
+       __asm("ldp      x0, x1, [sp, #16]");                            \
+       __asm("ldp      x2, x3, [sp, #32]");                            \
+       __asm("ldp      x4, x5, [sp, #48]");                            \
+       __asm("ldp      x6, x7, [sp, #64]");                            \
+       __asm("ldp      x29, x30, [sp], #80");                          \
        __asm("ret");                                                   \
        __asm(".size    " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
 
diff -r 4037d6b95d64 -r 5a945ac8882e sys/arch/arm/include/asm.h
--- a/sys/arch/arm/include/asm.h        Thu Apr 23 22:58:36 2020 +0000
+++ b/sys/arch/arm/include/asm.h        Thu Apr 23 23:22:41 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: asm.h,v 1.33 2020/04/21 11:35:02 joerg Exp $   */
+/*     $NetBSD: asm.h,v 1.34 2020/04/23 23:22:41 jakllsch Exp $        */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -145,7 +145,10 @@
 
 #ifdef GPROF
 # define _PROF_PROLOGUE        \
-       mov x9, x30; bl __mcount
+       stp     x29, x30, [sp, #-16]!;  \
+       mov     fp, sp;                 \
+       bl      __mcount;               \
+       ldp     x29, x30, [sp], #16;
 #else
 # define _PROF_PROLOGUE
 #endif



Home | Main Index | Thread Index | Old Index