Is there a way to rewrite a function signature so that it returns void, and what was once the return value is written into a pointer argument? I’ve seen some bits scattered around (it looks like it is possible to clone a function in LLVM, and there is a pass that erases a return argument from an MLIR function), but I could appreciate some direction.
My end goal is that the function returns void when lowered to LLVM and then translated to LLVM IR. Does it make sense to think of a new MLIR transformation, or should I lower/translate everything to LLVM and work there?
You’ll likely have to write your own transformation for this, either at the LLVM dialect level or directly on LLVM IR. There is no notion of pointer above that level.
It works both ways: functions that have a body in mlir get a wrapper that is callable from C, functions that don’t have a body (are assumed to have an implementation in C) get a wrapper that makes them callable from MLIR. More details here: LLVM IR Target - MLIR