[LLVMdev] llvm interpreter cannot execute llvm-gcc generated bitcode

Török Edwin edwintorok at gmail.com
Mon Feb 1 11:10:31 PST 2010

On 02/01/2010 01:13 PM, Kristaps Straupe wrote:
> Hello again!
> We have fetched the latest llvm sources from repository and the
> original problem has went away. Though now we are facing a new problem
> with interpreter on the following c code:
> --------------
> #include <stdarg.h>
> #include <stdio.h>
> void doTheThing(int dummy, ...)
> {
>   va_list ap;
>   int z;
>   va_start(ap, dummy);
>   while( (z = va_arg(ap, int))!=0)
>   {
>     printf("== %i ==\n", z);
>   }
>   va_end(ap);
> }
> int main()
> {
>   doTheThing(-1, 1, 2, 3, 0);
> }

I think this doesn't work because libffi doesn't support vararg functions:
"There is no support for calling varargs functions.  This may work on
some platforms, depending on how the ABI is defined, but it is not

Since you are on a platform where the JIT doesn't work properly, I guess
libffi's varargs
don't work either. What platform is it?

This only refers to external varargs functions, not ones you define
It works just fine with the JIT though.

I think it would be easier if you'd debug JIT problems this way (to
avoid running into libffi
limitations in the interpreter):
 1. compile your code with -O0 to LLVM BC
 2. compile the BC to native code (using llc + assembler + linker), test
that it works (output is correct)
 3. use the JIT to run the BC, test that it works properly (output is
 4. Repeat steps 1-3 with -O1, -O2, until it fails

Once you identified at which stage the problem occurs, you can try the
instructions here to further narrow down the problem:

Best regards,

More information about the llvm-dev mailing list