From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27950 invoked by alias); 4 Apr 2005 19:41:35 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 27941 invoked from network); 4 Apr 2005 19:41:32 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sourceware.org with SMTP; 4 Apr 2005 19:41:32 -0000 Received: from drow by nevyn.them.org with local (Exim 4.50 #1 (Debian)) id 1DIXRz-0005PV-MF; Mon, 04 Apr 2005 15:41:31 -0400 Date: Mon, 04 Apr 2005 19:41:00 -0000 From: Daniel Jacobowitz To: Eli Zaretskii Cc: gdb@sources.redhat.com, Reiner.Steib@gmx.de Subject: Re: Variable "foo" is not available Message-ID: <20050404194131.GA20570@nevyn.them.org> Mail-Followup-To: Eli Zaretskii , gdb@sources.redhat.com, Reiner.Steib@gmx.de References: <20050401171947.GA19058@nevyn.them.org> <01c53768$Blat.v2.4$d52008a0@zahav.net.il> <20050402142639.GA27550@nevyn.them.org> <01c537af$Blat.v2.4$c36667c0@zahav.net.il> <20050402184023.GA20247@nevyn.them.org> <01c537c6$Blat.v2.4$427763a0@zahav.net.il> <20050402210541.GA16758@nevyn.them.org> <01c538d4$Blat.v2.4$b261c020@zahav.net.il> <20050404133743.GA32163@nevyn.them.org> <01c5394c$Blat.v2.4$e4580a80@zahav.net.il> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01c5394c$Blat.v2.4$e4580a80@zahav.net.il> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-04/txt/msg00035.txt.bz2 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