[LLVMdev] Is va_arg correct on Mips backend?

Akira Hatanaka
Tue, 19 Feb 2013 19:04:24 -0000

Which part of the generated code do you think is not correct? Could you be
more specific?

I compiled this program with clang and ran it on a mips board. It returns
the expected result (21).

On Tue, Feb 19, 2013 at 4:15 AM, Jonathan <gamma_chen at yahoo.com.tw>
wrote:

> I check the Mips backend for the following C code fragment compile result.
> It seems not correct. Is it my misunderstand or it's a bug.
>
> //ch8_3.cpp
> #include <stdarg.h>
>
> int sum_i(int amount, ...)
> {
>   int i = 0;
>   int val = 0;
>   int sum = 0;
>
>   va_list vl;
>   va_start(vl, amount);
>   for (i = 0; i < amount; i++)
>   {
>     val = va_arg(vl, int);
>     sum += val;
>   }
>   va_end(vl);
>
>   return sum;
> }
>
> int main()
> {
>   int a = sum_i(6, 1, 2, 3, 4, 5, 6);
>
>   return a;
> }
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130219/3b29ef34/attachment.html>