InstrRefBasedLDV is marginally slower than VarlocBasedLDV when analysing optimised code -- however, it's much slower when analysing code compiled -O0. Up to 25% slower according to [0], which is too much!
To avoid this: don't use instruction referencing for -O0 functions. In the "pure" case of unoptimised code, this won't really harm the debugging experience because most variables won't have been promoted off the stack, so can't go missing. It becomes more complicated when optimised code is inlined into functions marked optnone; however these are rare, and as -O0 doesn't run many optimisations there should be little damage to the debug experience as a result.
I've taken the opportunity to refactor testing for instruction-referencing into a MachineFunction method, which seems the most appropriate place to put it.
Nit/question. Am I right in thinking this returns the same value for all MachineFunctions?
If so, then maybe this method should be static? And in the comment I think functions should just become function or be removed. Alternatively, if I'm wrong and this can return a different value for different MachineFunctions (or may do so in the future), then I think the comment should start Returns true if the function's variable....