Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386/include use compiler builtins to compute addre...



details:   https://anonhg.NetBSD.org/src/rev/de104e0ce543
branches:  trunk
changeset: 824551:de104e0ce543
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jun 08 18:25:14 2017 +0000

description:
use compiler builtins to compute addresses instead %ebp assembly arithmetic.
(from joerg)

diffstat:

 sys/arch/i386/include/profile.h |  12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diffs (35 lines):

diff -r 94ecf0e02252 -r de104e0ce543 sys/arch/i386/include/profile.h
--- a/sys/arch/i386/include/profile.h   Thu Jun 08 18:24:39 2017 +0000
+++ b/sys/arch/i386/include/profile.h   Thu Jun 08 18:25:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: profile.h,v 1.36 2017/06/04 16:35:59 christos Exp $    */
+/*     $NetBSD: profile.h,v 1.37 2017/06/08 18:25:14 christos Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -54,8 +54,7 @@
 #define        MCOUNT \
 MCOUNT_COMPAT                                                          \
 extern void mcount(void) __asm(MCOUNT_ENTRY)                           \
-       __attribute__((__no_instrument_function__))                     \
-       __attribute__((__optimize__("-fno-omit-frame-pointer")));       \
+       __attribute__((__no_instrument_function__));                    \
 void                                                                   \
 mcount(void)                                                           \
 {                                                                      \
@@ -72,12 +71,11 @@
         *                                                              \
         * selfpc = pc pushed by mcount call                            \
         */                                                             \
-       __asm volatile("movl 4(%%ebp),%0" : "=r" (selfpc));             \
+       selfpc = (int)__builtin_return_address(0);                      \
        /*                                                              \
-        * frompcindex = pc pushed by call into self.                   \
+        * frompcindex = stack frame of caller, assuming frame pointer  \
         */                                                             \
-       __asm volatile("movl (%%ebp),%0" : "=r" (frompcindex));         \
-       frompcindex = ((int *)frompcindex)[1];                          \
+       frompcindex = ((int *)__builtin_frame_address(1))[1];           \
        _mcount((u_long)frompcindex, (u_long)selfpc);                   \
                                                                        \
        __asm volatile("movl %0,%%edx" : : "g" (edx));                  \



Home | Main Index | Thread Index | Old Index