Debugging JIT module and IR for a custom frontend

The frontend I’m writing for a format X is producing incorrect IR. This IR module is meant to be a JITed interface between components of the caller, ie: The caller parses format X, JITs it, the JITed module is called, then it calls back into the caller, all with the C ABI.

I suspect incorrect gep instructions, but don’t know exactly what is wrong, one to many or too few loads, incorrect offsets, etc.

  • I looked at lli however the generated module needs context from the caller to work and the source format is not anything meaningful to look at, I don’t think it can help me there. Debugging JIT-ed Code — LLVM 17.0.0git documentation
  • Debugging the caller with lldb works but completely skips over the JIT module and the values received back are garbage (which is the problem).
  • The module could be instrumented such that individual values get passed to function calls with break points purely for probing those values but that’s a lot of added code generation just to be able to see whats going on.
  • It would help to be able to debug the caller and be able to then jump to a source file containing the generated IR and step on each instruction to see whats going on to fix it. There is this conversation https://groups.google.com/g/llvm-dev/c/O4Dj9FW1gtM/m/ovnm6dqoJJsJ, however I have not been able to find anything newer about the mentionned pass.

Any help is appreciated and llvm is quite new to me so I wouldn’t be surprised to be missing something obvious.

Thank you

Edit
I figured out the problem by writing an equivalent program in https://godbolt.org/ and comparing the emitted IR with my own.