Hello,

Compiling the following with mspgcc:


void dummy(int a) {}

void fn(int p1, int p2, int p3, int p4, int p5)
{
    char *buf;
    dummy(p5);
    buf = alloca(2);
}

int main()
{
    fn(1, 2, 3, 4, 5);
    return 0;
}


Generates this assembly for fn:

00004038 <fn>:
    4038:       0b 12           push    r11             
    403a:       05 12           push    r5              
    403c:       04 12           push    r4              
    403e:       2f 45           mov     @r5,    r15     
    4040:       0b 41           mov     r1,     r11     
    4042:       b0 12 36 40     call    #0x4036 
    4046:       21 82           sub     #4,     r1      ;r2 As==10
    4048:       01 4b           mov     r11,    r1      
    404a:       34 41           pop     r4              
    404c:       35 41           pop     r5              
    404e:       3b 41           pop     r11             
    4050:       30 41           ret                     

This is wrong, since it reads parameter p5 from @r5, but nothing was
written to r5 in the function. This only happens with parameters
passed in the stack in functions using alloca, and compiled with -O2.
I've tested this with the last Windows version and a Linux version
compiled from SVN around July.

Can anyone confirm this issue?

Thanks!
Conrado

Reply via email to