Avoid a crash when using instruction referencing if x87 floating point instructions are used. These instructions are significantly mutated when they're rewritten from referring to registers, to referring to floating-point-stack positions. As a result, their operands are re-ordered, and (InstrRef) LiveDebugValues asserts when it sees a DBG_INSTR_REF referring to a non-reg non-def register operand.
To fix this, I'm just dropping the instruction numbers, and thus variable locations. This avoids the crash -- we could try and record the substitution from fp-register operand to floating-point-stack-position but then... what would we do with the floating point stack position? They shift position throughout the program, and an additional dataflow analysis would be needed to work out how to refer to them correctly.
Instead, take the pragmatic approach that VarLoc LiveDebugvalues / variable locations does, and drop the lot of them. This isn't a coverage regression at all, because all DBG_VALUEs of, for example, $fp0, don't make it to the output file because they're pseudo-registers with no DWARF register number. I'll open a PR for poor x87 variable location support, however I suspect interest is limited.
This patch adds a "dropDebugNumber" helper to MachineInstr, the idea being that it's (sort-of) self documenting what's going on. The attached test case covers all six call sites that I add in the x86-codegen pass.