All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@debian.org>
To: linux-mips@oss.sgi.com, gcc-bugs@gcc.gnu.org
Cc: Simon Gee <simong@oz.agile.tv>
Subject: MIPS, profiling, and not working
Date: Tue, 14 Aug 2001 15:09:24 -0700	[thread overview]
Message-ID: <20010814150924.A19477@nevyn.them.org> (raw)

I'm having some interesting problems with getting _mcount() to work on
mips*-*-linux.  Most of them are easily correctable within _mcount itself,
but one deals with how it's called.  The sequence looks like this:

        .set    noreorder
        .set    noat
        move    $1,$31          # save current return address
        jal     _mcount
        subu    $sp,$sp,8               # _mcount pops 2 words from  stack
        .set    reorder
        .set    at

Suppose we have a function with no frame pointer, though - one which would
otherwise be a leaf.  We have a small problem based on the fact that
GCC considers it to be a leaf despite calling _mcount.  If it uses $sp for
its frame register, then when the jal expands:

0x404550 <__libc_start_main+16>:        sw      $gp,16($sp)

...

0x404574 <__libc_start_main+52>:        move    $at,$ra
0x404578 <__libc_start_main+56>:        lw      $t9,-32584($gp)
0x40457c <__libc_start_main+60>:        nop
0x404580 <__libc_start_main+64>:        jalr    $t9
0x404584 <__libc_start_main+68>:        nop
0x404588 <__libc_start_main+72>:        lw      $gp,16($sp)
0x40458c <__libc_start_main+76>:        addiu   $sp,$sp,-8


Note that we saved $gp at 16($sp), then tried to restore it before we fixed
$sp up again.

Does anyone have a good idea?  The best I can think of is to emit the jalr
from GCC directly, so that we can restore the GP after restoring the stack
pointer properly.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

             reply	other threads:[~2001-08-14 22:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-14 22:09 Daniel Jacobowitz [this message]
2001-08-14 23:53 ` MIPS, profiling, and not working Simon Gee
2001-08-14 23:44   ` Daniel Jacobowitz
2001-08-15  0:11     ` Jun Sun
2001-08-16 10:12     ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010814150924.A19477@nevyn.them.org \
    --to=dan@debian.org \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=linux-mips@oss.sgi.com \
    --cc=simong@oz.agile.tv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.