avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Stack use - possible bug


From: Jan Waclawek
Subject: Re: [avr-gcc-list] Stack use - possible bug
Date: Wed, 9 Jun 2010 17:52:16 +0200

Wouter, that's it. I always tried the simplified examples using arrays of the 
same size.

The following:

#include <stdint.h>
volatile uint8_t b;

int main (void) {
  while(1) {
    {
      uint8_t a1[200];
      b = a1[b];
    }
    {
      uint8_t a2[210];
      b = a2[b];
    }
  }
}


(The read to volatile uint8_t b is to prevent the optimiser to get rid of the 
arrays altogether).
As a1[] and a2[] have limited scope/life in non-overlapping blocks, they may 
and should use the same stack space.
However

  11                    main:
  12 0000 DF93                  push r29
  13 0002 CF93                  push r28
  14 0004 CDB7                  in r28,__SP_L__
  15 0006 DEB7                  in r29,__SP_H__
  16 0008 CA59                  subi r28,lo8(-(-410))
  17 000a D140                  sbci r29,hi8(-(-410))

i.e. stack frame of 200 + 210 bytes is used.

The inlined functions are only a variation of this problem.

Still I wouldn't call this a bug, but that's just terminology. Let's just call 
it a serious case of missed optimisation... :-)

Jan Waclawek






reply via email to

[Prev in Thread] Current Thread [Next in Thread]