public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/51002] New: SP_H register is used even on targets that do not have it (eg attiny26)
@ 2011-11-06 21:06 wiml at hhhh dot org
  2011-11-26 20:52 ` [Bug target/51002] " gjl at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: wiml at hhhh dot org @ 2011-11-06 21:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51002

             Bug #: 51002
           Summary: SP_H register is used even on targets that do not have
                    it (eg attiny26)
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: wiml@hhhh.org
            Target: avr


Not all of the AVR parts implement a full 16-bit-wide stack pointer; on (for
example) the ATtiny26/ATtiny261, the stack pointer is 8 bits wide and the SP_H
register (at 0x3E) is not implemented. GCC 4.6.2 is smart enough to manipulate
only the lower 8 bits of the stack pointer in the function prologue/epilogue,
but it still attempts to load the upper 8 bits from the nonexistent SP_H
register, resulting in the upper 8 bits of any stack-relative pointer
containing a garbage value:


extern void bar(char *c);
void foo()
{
    char buf[16];
    bar(buf);
}

$ avr-gcc -Os -fverbose-asm -S -mmcu=attiny26 stkbuf.c  

foo:
        push r28         ; 
        push r29         ; 
        in r28,__SP_L__  ; 
        in r29,__SP_H__  ; 
        subi r28,lo8(-(-16))     ; ,
        out __SP_L__,r28         ; 
/* prologue: function */
/* frame size = 16 */
/* stack size = 18 */
.L__stack_usage = 18
        mov r24,r28      ; ,
        mov r25,r29      ; ,
        adiw r24,1       ; ,
        rcall bar        ; 
[etc]


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-03-28 11:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-06 21:06 [Bug target/51002] New: SP_H register is used even on targets that do not have it (eg attiny26) wiml at hhhh dot org
2011-11-26 20:52 ` [Bug target/51002] " gjl at gcc dot gnu.org
2011-11-26 21:47 ` wiml at hhhh dot org
2011-12-02 19:14 ` gjl at gcc dot gnu.org
2011-12-06 15:04 ` gjl at gcc dot gnu.org
2012-01-04 15:29 ` gjl at gcc dot gnu.org
2012-03-18 15:24 ` himself@claus-justus-heine.de
2012-03-18 20:30 ` gjl at gcc dot gnu.org
2012-03-18 21:38 ` himself@claus-justus-heine.de
2012-03-18 21:56 ` gjl at gcc dot gnu.org
2012-03-18 22:49 ` himself@claus-justus-heine.de
2012-03-27 18:09 ` gjl at gcc dot gnu.org
2012-03-28 10:28 ` gjl at gcc dot gnu.org
2012-03-28 11:07 ` gjl at gcc dot gnu.org

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).