Forward references to a function

JIT::runJITOnFunctionUnlocked makes sure that functions referenced by the current function are JIT-ed. In my case, I may be compiling foo(), during which I notice that I need to build bar(), which refers to foo(). The compiler dies JIT-ing foo() because it's not done yet. Specifically, I'm in the middle of generating one of the BBs of foo(), so it doesn't have a terminating instruction and I assert with:

Assertion failed: (T && "getTerminator returned null!"), function SuccIterator, file /Users/ddd/Development/llvm/include/llvm/Support/CFG.h, line 99.

I have checked that ExecutionEnding::DisableLazyCompilation() fixes it. Am I supposed to enable lazy JIT in that case? That's not really what i want, what I really would like is to be able to state that a function is "in progress" to make sure it doesn't get added to the pending list. Much like a forward reference in C.

Thanks in advance,

Yes, you need a complete dependency graph to JIT a function. You're
expected to wait to JIT your function until you might actually be able
to call it. To do anything else, we'd probably need a way to record
relocations outside the JIT and let you apply them ... which would be
useful but hasn't been at all started yet.