Re: [cc65] Stack usage optimization

From: Spiro Trikaliotis <>
Date: 2010-09-13 20:48:53

* On Mon, Sep 13, 2010 at 05:00:11PM +0200 Jakub wrote:

> In this case one byte is wasted, while both functions could use the same  
> stack space. In bigger programs it can eat up to a few hunderd bytes. 
> What about computing graph of function calls and automatically allocate 
> same addresses for local variables of function that do not call each 
> other?

You are aware that "computing graph of function calls" and finding out
which local variables can be used safely in this way is a very costly
operation, and nothing you write on an afternoon? Furthermore, you must
make sure that you considered every single issue (cf. Marc 'BlackJack'
Rintsch' comment)?

In your special case, you could even ask for a liveliness determiniation
which would completely optimise away both local variables, and even both
functions. (I am neglecting the fact that the function have external
linkage here.) All of this can be done, but it is some work to do it
right so that it works not only in some artificial cases (like your
example), but always in a reliable way.

I am sure Uz will consider your patch once you have send it to him. :)


Spiro R. Trikaliotis                               
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Sep 13 20:49:08 2010

This archive was generated by hypermail 2.1.8 : 2010-09-13 20:49:11 CEST