I've noticed that msp430-gcc 3.2.3 often generates
unnecessarily large frame sizes?

For example for a function containing a large switch statement,
the frame size will be the _sum_ of the frame sizes required
for each of the cases.  If each of the 10 cases declares a
single "float", the function's frame size will be 40 even
though there's no execution path that requires more than 4.

Adding a single float variable outside the switch statement and
using it in all of the cases will cut the framesize
drastically, though it makes the code hard to read because it
means you have a single floating point variable with a
meaningless name like "f" being used for 10 completely
unrelated things.

Similar things happen for code like this:

void foo(void)
{
   float x,y;

   if (whatever)
      {
      float xx,yy;
      <whatever>;
      }
   else
      {
      float vv,zz;
      <whatever>;      
      }

   <whatever>      
}

The compiler seems to allocate frame space for both
x,y,xx,yy,vv,zz Changing xx,yy and vv,zz to x,y in both
branches of the if/else will cut the frame size by 1/2 to 2/3.

Why can't the compiler figure out that the lifetimes of x,y and
xx,yy and vv,zz don't overlap?

The only want to keep RAM usage down to a reasonable value,
seems to be to use global variables everywhere possible and do
the lifetime overlapping checking in your head.  

Ew.

-- 
Grant Edwards                   grante             Yow!  Everybody is going
                                  at               somewhere!! It's probably
                               visi.com            a garage sale or a disaster
                                                   Movie!!


Reply via email to