[RFC] Instruction API changes needed to eliminate debug intrinsics from IR

It didn’t fix all instances of the error, but the next one I encountered is where the error is useful, where it highlights a real problem: building one module in memory, implicitly using the new debug info format, loading another module from disk, implicitly using the old debug info format, and copying functions over from one to the other. That would go wrong if the error were just ignored, so I appreciate the error.

Possibly something else in LLVM should be changed there, it seems unfortunate that it’s possible to implicitly mix debug info formats; I would have expected that any code that does not touch debug info format either consistently uses the old format, or the new format.

It’s not just subtle mostly harmless debug info that changes, in my case it also resulted in a PHI being inserted in the wrong place, meaning debug info appeared before PHIs, which LLVM then hit an assertion failure on.

If anyone else hits this before the new API changes go in, the versions that do not insert an instruction, and then manually inserting the instruction, works fine.