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 - prevent optimization from omitting t...



details:   https://anonhg.NetBSD.org/src/rev/a288ec3e4656
branches:  trunk
changeset: 824421:a288ec3e4656
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jun 04 16:35:59 2017 +0000

description:
- prevent optimization from omitting the frame pointer (and re-using it);
  we use it in our inline assembly.
- convert to c a little assembly to make the code more understandable.

diffstat:

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

diffs (30 lines):

diff -r 48f53f0150f0 -r a288ec3e4656 sys/arch/i386/include/profile.h
--- a/sys/arch/i386/include/profile.h   Sun Jun 04 15:08:30 2017 +0000
+++ b/sys/arch/i386/include/profile.h   Sun Jun 04 16:35:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: profile.h,v 1.35 2017/05/31 01:50:19 christos Exp $    */
+/*     $NetBSD: profile.h,v 1.36 2017/06/04 16:35:59 christos Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -54,7 +54,8 @@
 #define        MCOUNT \
 MCOUNT_COMPAT                                                          \
 extern void mcount(void) __asm(MCOUNT_ENTRY)                           \
-       __attribute__((__no_instrument_function__));                    \
+       __attribute__((__no_instrument_function__))                     \
+       __attribute__((__optimize__("-fno-omit-frame-pointer")));       \
 void                                                                   \
 mcount(void)                                                           \
 {                                                                      \
@@ -75,8 +76,8 @@
        /*                                                              \
         * frompcindex = pc pushed by call into self.                   \
         */                                                             \
-       __asm volatile("movl (%%ebp),%0;movl 4(%0),%0"                  \
-           : "=r" (frompcindex));                                      \
+       __asm volatile("movl (%%ebp),%0" : "=r" (frompcindex));         \
+       frompcindex = ((int *)frompcindex)[1];                          \
        _mcount((u_long)frompcindex, (u_long)selfpc);                   \
                                                                        \
        __asm volatile("movl %0,%%edx" : : "g" (edx));                  \



Home | Main Index | Thread Index | Old Index