Debug assertion when moving from LLVM 7 to LLVM 8.

I have an application which works without asserting when using LLVM 7.

After upgrading to LLVM 8, whenever I try to generate debug records, I get the following assertion:

/home/dej/work/llvm_git/llvm-project/llvm/lib/IR/Metadata.cpp:634: void llvm::MDNode::resolveCycles(): Assertion `!N->isTemporary() && “Expected all forward declarations to be resolved”’ failed.

Interestingly, this assert exists in LLVM 7, but my application does not trigger it. I can only conclude that requirements have changed - some new requirement has been added to achieve “resolution”.

Does anyone know what the new requirements could be? Alternatively, how would I debug this?