public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb@sources.redhat.com, Reiner.Steib@gmx.de
Subject: Re: Variable "foo" is not available
Date: Mon, 04 Apr 2005 19:41:00 -0000	[thread overview]
Message-ID: <20050404194131.GA20570@nevyn.them.org> (raw)
In-Reply-To: <01c5394c$Blat.v2.4$e4580a80@zahav.net.il>

On Mon, Apr 04, 2005 at 10:30:23PM +0300, Eli Zaretskii wrote:
> But this kind of code is only possible if the compiler examines all
> the callers of `bar' and finds that none of them uses the value of
> `bar's argument after `bar' returns.  So such code is probably only
> possible in practice with static functions, right?  Or am I missing
> something?

That would be true if the ABI labeled the stack slots as preserved
across the function call.  The consensus seems to be that it does not;
at the point of the function call they become part of the callee's
stack frame and it is free to modify them.

> Also, is such optimizations really worth it?  I mean, the more
> traditional code will mov the argument into a register and do the math
> there; is adding to a memory location really faster than a mov and a
> register-based add?

Yes, especially on decoding-limited processors.

Also, sibling calling does the same thing.  It reuses the stack slots
to pass arguments to a new function, and then jumps to the function.

> > GCC won't reuse the slot for an unrelated variable at present. 
> > However, in the future, it would be a valid optimization.
> 
> Again, only if the compiler has enough information about the callers,
> right?

No, as above.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

  reply	other threads:[~2005-04-04 19:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-01 16:40 Reiner Steib
2005-04-01 17:19 ` Daniel Jacobowitz
2005-04-02  9:49   ` Eli Zaretskii
2005-04-02 13:53     ` Reiner Steib
2005-04-02 14:27       ` Daniel Jacobowitz
2005-04-06 16:25         ` Reiner Steib
2005-04-02 14:26     ` Daniel Jacobowitz
2005-04-02 18:17       ` Eli Zaretskii
2005-04-02 18:40         ` Daniel Jacobowitz
2005-04-02 20:58           ` Eli Zaretskii
2005-04-02 21:05             ` Daniel Jacobowitz
2005-04-04  5:14               ` Eli Zaretskii
2005-04-04  6:00                 ` Mark Kettenis
2005-04-04  7:58                 ` Daniel THOMPSON
2005-04-04 19:28                   ` Eli Zaretskii
2005-04-04 13:37                 ` Daniel Jacobowitz
2005-04-04 19:35                   ` Eli Zaretskii
2005-04-04 19:41                     ` Daniel Jacobowitz [this message]
2005-04-03 18:16           ` Reiner Steib
2005-04-08 11:05       ` Eli Zaretskii
2005-04-04  9:26     ` Reiner Steib

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=20050404194131.GA20570@nevyn.them.org \
    --to=drow@false.org \
    --cc=Reiner.Steib@gmx.de \
    --cc=eliz@gnu.org \
    --cc=gdb@sources.redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).