How to generate IR for functions taking complicated C++ types as arguments?

I’m currently working on a project that JIT compiles traces of C++ functions to new functions optimized for the particular input. I have IR generation mostly working, except: these functions take complicated C++ types (specifically std::vector<double>, a struct containing fields with std::vector types, and Eigen::Transform from Eigen: Eigen::Transform< Scalar_, Dim_, Mode_, Options_ > Class Template Reference) as arguments, and I don’t know how to generate a function type that includes these types.

I’ve tried looking at the IR clang++ generates for a similar function, and it appears to include a long hierarchy of types corresponding to the Eigen and std::vector argument types. However, I’m not sure if I can safely include the same hierarchy in my code, as I don’t know if it’s machine specific, etc.

I’m thinking of avoiding the complexity of generating the calls necessary to access elements from these types by providing a runtime library with a simplified interface, but I still need to figure out how to express these types correctly in IR for that approach to work.

Is there an easy way around this, e.g. by using an opaque structure type or something? Thanks!

Depending on what you are trying to achieve, you could potentially pass-by-reference/pointer instead of by-value.

E.g., if your functions only uses the std::vector as input/output array, but don’t use push_back etc., you could in your C++ coe, before calling your code-gened function, simply unpack vec.data() and vec.size() and pass both into your LLVM-generated function

Thanks! I came to a similar conclusion myself - I think I can just pass in void*s for the input and output data structures, and provide functions that take these pointers and an index to return the correct double.