[LLVMdev] Matching struct layouts.

Mahadevan R mdevan.foobar at gmail.com
Thu May 15 02:34:10 PDT 2008


Hi.

I've a situation where I need to build and execute a function on the
fly (with LLVM of course :-). The function will need to take a pointer
to a C struct, which is defined by the host. That is, the built
function will be something like:

void func(struct XYZ *p)
{
    /* need to access members of p here */
}

How will I educate LLVM IR about 'struct XYZ' so that the code inside
can access it's members properly? How can I be sure that the alignment
and padding of the members of the existing struct layout and the LLVM
struct layout matches?

In the worst case I can construct the function as taking individual
struct members as individual parameters, but that would be inelegant..

Thanks,
-Mahadevan.



More information about the llvm-dev mailing list