Passing structs in C calling convention


I want to declare a function that matches C ABI. Do I need to transform declarations like void @f(%struct.A %a) into void @f(%struct.A* byval %a) myself or LLVM can do it for me? Is this what “ccc” calling convention means?

  • Paweł

LLVM doesn’t have enough information to do it for you. The LLVM type system just isn’t as expressive as the C type system, so frontends end up bearing some of the lowering burden.

You should consider using clang to do the lowering for you:

Thanks for explaining that to me.

So the conclusion is to use IRGen from Clang to handle the lowering, right? I will take a look there and try to use it. But that adds additional dependency what’s is not ideal.