<div class="gmail_quote">2010/2/1 Török Edwin <span dir="ltr"><<a href="mailto:edwintorok@gmail.com">edwintorok@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="im">On 02/01/2010 01:13 PM, Kristaps Straupe wrote:<br>
> Hello again!<br>
><br>
> We have fetched the latest llvm sources from repository and the<br>
> original problem has went away. Though now we are facing a new problem<br>
> with interpreter on the following c code:<br>
><br>
> --------------<br>
> #include <stdarg.h><br>
> #include <stdio.h><br>
><br>
> void doTheThing(int dummy, ...)<br>
> {<br>
>   va_list ap;<br>
>   int z;<br>
><br>
>   va_start(ap, dummy);<br>
>   while( (z = va_arg(ap, int))!=0)<br>
>   {<br>
>     printf("== %i ==\n", z);<br>
>   }<br>
>   va_end(ap);<br>
> }<br>
><br>
> int main()<br>
> {<br>
>   doTheThing(-1, 1, 2, 3, 0);<br>
> }<br>
><br>
<br>
</div>I think this doesn't work because libffi doesn't support vararg functions:<br>
"There is no support for calling varargs functions.  This may work on<br>
some platforms, depending on how the ABI is defined, but it is not<br>
reliable."<br></blockquote><div><br>I don't think that's the problem. The call to doTheThing shouldn't involve libffi since it's not an external call, and the call to printf doesn't involve libffi since it's a hard-coded known-varargs function. See the table at the end of lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp for a list of functions we trap instead of sending to libffi.<br>

<br>I have no idea why it's failing yet.<br><br>Nick<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Since you are on a platform where the JIT doesn't work properly, I guess<br>
libffi's varargs<br>
don't work either. What platform is it?<br>
<br>
This only refers to external varargs functions, not ones you define<br>
yourself.<br>
It works just fine with the JIT though.<br>
<br>
I think it would be easier if you'd debug JIT problems this way (to<br>
avoid running into libffi<br>
limitations in the interpreter):<br>
 1. compile your code with -O0 to LLVM BC<br>
 2. compile the BC to native code (using llc + assembler + linker), test<br>
that it works (output is correct)<br>
 3. use the JIT to run the BC, test that it works properly (output is<br>
correct)<br>
 4. Repeat steps 1-3 with -O1, -O2, until it fails<br>
<br>
Once you identified at which stage the problem occurs, you can try the<br>
instructions here to further narrow down the problem:<br>
<a href="http://llvm.org/docs/HowToSubmitABug.html#codegen" target="_blank">http://llvm.org/docs/HowToSubmitABug.html#codegen</a><br>
<br>
Best regards,<br>
<font color="#888888">--Edwin<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br>