Mips backend 3.2 va_arg possible bug

i have this code

typedef long long L;
typedef integer I;
void test2(auto L p0, auto L p1, auto L p2, auto L p4, ...)
{
  va_list select;
            
  va_start (select, p4);
                             
  report( va_arg(select,L) );
  report( va_arg(select,I) );
  report( va_arg(select,L) );
                        
  va_end (select);
}

int main(void)
{
    test2(1, 2, 3, 4, 5LL, 6, 7LL);
    return 0;
}

report is just a function that prints the results.

in main the assemply code seems to be ok but in test2 function does
something that seems to be wrong

i use "llc -march=mipsel -relocation-model=static -asm-verbose
-mattr=+condmov,-muldivadd,+single-float,-fp64,+o32,-bitcount " command

in function we report the values of a long long value then an integer value
and then again a long long
so the problem is that in the test2 function there is an addiu
$3, $2, 4
that causes the third long long value to be read from wrong address.
mipsel.s <http://llvm.1065342.n5.nabble.com/file/n55498/mipsel.s>

        .set nomacro
# BB#0: # %entry
        addiu $sp, $sp, -24
        sw $ra, 20($sp) # 4-byte Folded Spill
        addiu $2, $sp, 56
        sw $2, 16($sp)
        addiu $2, $2, 8
        sw $2, 16($sp)
        lw $5, 60($sp)
        lw $4, 56($sp)
        jal _Z6reportx
        nop

        lw $2, 16($sp)
#problem starts here

        addiu $3, $2, 4

#problem stops here
        sw $3, 16($sp)
        lw $4, 0($2)
        jal _Z6reporti
        nop
        lw $2, 16($sp)
        addiu $3, $2, 8
        sw $3, 16($sp)
        lw $5, 4($2)
        lw $4, 0($2)

        jal _Z6reportx
        nop
        lw $ra, 20($sp) # 4-byte Folded Reload
        addiu $sp, $sp, 24
        jr $ra
        nop
        .set macro
        .set reorder
        .end _Z5test2xxxxz

Could you file a bug?

did it :slight_smile:

http://llvm.org/bugs/show_bug.cgi?id=15389