[LLVMdev] Passing pointers to pointers to JIT

Zack Rusin zack at tungstengraphics.com
Mon Oct 8 06:50:43 PDT 2007


Hey,

we're trying to pass multidimensional arrays to JIT where one of the helper 
functions should convert them to LLVM vector types. Unfortunately passing a 
multidimensional array seems to crash the JIT and I'm not sure why.

As an example, we have a file with two silly C functions:
http://ktown.kde.org/~zrusin/llvm/llvm.c
Both clang (latest svn) and llvm-gcc (4.0.1) produce basically the same ll 
code looking like this:
http://ktown.kde.org/~zrusin/llvm/llvm.ll
And now calling those functions from a cpp file looking like this:
http://ktown.kde.org/~zrusin/llvm/test.cpp
gives proper results for the single-dimensional array, but crashes on 
multi-dimensional case.

It looks like argument passing to those functions with the:
std::vector<GenericValue> args(2);
args[0]        = PTOGV(array);
args[1].IntVal = APInt(32, arraySize);
scheme is ok when "array" is single dimensional but invalid when "array" is 
multi-dimensional. 

What is the proper way of passing multi-dimensional arrays from C/C++ code to 
LLVM JIT? If someone could let me know what I'm doing wrong and how to get 
this to work, that'd be great. Or alternatively does anyone have a function 
that would convert arrays of the form float[n][4] into array of vectors of  
[n x <4 x float>] format and back?

Zack



More information about the llvm-dev mailing list