dump intermediate state of a module or a function

I want to dump an unfinished state of the whole IR of a module or
function for debugging purposes.

`llvm::WriteBitcodeToFile` does not suit my needs since it calls
validations on the module that will be failed in general for an
unfinished IR

Even debugging with lldb, sometimes is very hard to detect why the
same code generation works correctly in some cases, and in others the
llvm will trigger an invalid cast assertion. Having a partial state of
the IR for debugging would really, really help me out to reject
possible issues

Can you use module->dump()?