When using struct parameters in a function, clang will change the function signature. Instead of using a struct type, the signature will be a coerced int of equal size. In m
Two month ago there was a thread in llvmdev: [LLVMdev] "Struct parameters being converted to other types" by Jaymie Strecker, Jan 14 19:50:04 CST 2013. She encountered similar problem: "When a function with a struct parameter or return type is compiled with clang -O0 -emit-llvm
, the resulting bitcode varies greatly depending on the type of struct.", and clang turned struct into pointer, vector, passed it as several doubles, or merged into single i64 type. Anton Korobeynikov replied at Jan 15 00:41:43 CST 2013:
The struct is lowered to something which corresponds to C/C++ ABI on your platform for passing the struct in proper way.
So, clang does struct passing according to the way used by your OS, libs and native compiler. This is done to allow you build modules, which will work with local libraries. I think that your compiler project uses wrong ABI.
You can fix your compiler project to use platform ABI (convert structs like it was done by clang), OR you can define your own ABI and tune clang to use it.