This is the "central" patch to the removing-debug-intrinsics project: it changes the instruction movement APIs (insert, move, splice) to interpret the "Head" bits we're attaching to BasicBlock::iterators, and updates debug-info records in the background to preserve the ordering of debug-info (which is in DPValue objects instead of dbg.values). The cost is the complexity of this patch, plus memory. The benefit is that LLVM developers can cease thinking about whether they're moving debug-info or not, because it'll happen behind the scenes.
To get an idea of what's going on, immediately skip to looking at the comment in BasicBlock::spliceDebugInfo. In dbg.value form, variable location information gets moved around automatically because it's an instruction, and it always stays in the right order. However, once converted into DPValue objects, we have to do this manually. The presence of the "head" bits on iterators indicates whether or not a transfer of instructions is intended to include the leading debug-info or not (in one scenario: the trailing debug-info). BasicBlock::splice now interprets those and moves DPValues around as appropriate. The range of transfers that can be described in splice() is explicitly enumerated in the unit test added, and there's a worked example in each scenario for clarity.
The rest of this patch applies the same reasoning in a variety of scenarios. When moveBefore (and it's siblings) are used to move instructions around, the caller has to indicate whether they intend for debug-info to move too (is it a "Preserving" call or not), and then the "Head" bits used to determine where debug-info moves to. Similar reasoning is needed for insertBefore.
Some utility methods are added to Instruction to allow examining whether an instruction has debug-info attached to it or not.
nit: from_here -> FromHere