Module Name: src Committed By: jakllsch Date: Thu Apr 23 23:22:41 UTC 2020
Modified Files: src/sys/arch/aarch64/include: profile.h src/sys/arch/arm/include: asm.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/profile.h cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/asm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/aarch64/include/profile.h diff -u src/sys/arch/aarch64/include/profile.h:1.1 src/sys/arch/aarch64/include/profile.h:1.2 --- src/sys/arch/aarch64/include/profile.h:1.1 Sun Aug 10 05:47:38 2014 +++ src/sys/arch/aarch64/include/profile.h Thu Apr 23 23:22:41 2020 @@ -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); Index: src/sys/arch/arm/include/asm.h diff -u src/sys/arch/arm/include/asm.h:1.33 src/sys/arch/arm/include/asm.h:1.34 --- src/sys/arch/arm/include/asm.h:1.33 Tue Apr 21 11:35:02 2020 +++ src/sys/arch/arm/include/asm.h Thu Apr 23 23:22:41 2020 @@ -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