Completely change the way we turn DBG_VALUE machine instructions
into location information for local variables. This is inspired by discussion
in r128327 review thread.
We used to terminate location range for each variable at the end of the basic
block with DBG_VALUE for it. This is incorrect, e.g. the register used to hold
the variable location may be never clobbered in the entire function, so one
DBG_VALUE is enough to define the location of a variable in the whole function.
Now we actually analyze the control flow: calculate the presumed location of
a variable at the end and the beginning of each basic block. For example,
if the location of a variable is the same at the end of all predecessors of
basic block B, we may assume that we know the location of a variable in B,
and avoid terminating the location range too early.
I think it's pretty much all we can do w/o actually changing the CodeGen for
DBG_VALUE instructions.
If you agree with the direction of this patch, I should probably test it
extensively. There are many concerns:
0) Correctness. LLVM/Clang regression tests don't really check anything -
we should run it on gdb test-suite or smth. comprehensive.
- Debug info size. We should verify that .debug_loc section wouldn't explode.
- Compilation time - in the worst case we smth. like O(NumVars * NumInstructions), which can be a lot for large functions.