This patch does 2 things:
a. Provides an infrastructure to represent multiple locations for debug variables by addition of the flag - PreserveDbgValLoc and handling it at DbgValueHistoryCalculator and buildLocationLists code.
b. Infer multiple locations from copies in DebugValueFixup (yet to be renamed) code.
This patch was initially submitted at http://reviews.llvm.org/D11933 and inferring multiple locations happen on top of that patch.
Short description:
LLVM currently can represent a debug variable only at a single location. This patch provides an infrastructure for earlier passes to express multiple locations for a debug variable by adding a new flag - PreserveDbgValLoc to the DBG_VALUE instruction. The presence of the flag will mean multiple debug ranges for the variable can co-exist together. The patch also infers multiple locations by looking at move instructions.
Example - inferring from move instruction: Consider the following two instructions: DBG_VALUE %EDI, %noreg, !"n", <!12> %EBX<def> = MOV32rr %EDI DBG_VALUE %EBX, %noreg, !"n", <!12>; flags: PreserveDbgValLoc <-- newly inserted
After the copy instruction, the value “n” will be present in two locations - %EDI and %EBX and the same is represented with the new DBG_VALUE instruction having the flag PreserveDbgValLoc set.
The two ranges continue to exist together until one of the following happens:
Either %EDI or %EBX is clobbered, the two ranges are conservatively ended
A DBG_VALUE instruction for variable “n” without the flag is seen, when the previous ranges are ended.
Document (if needed): https://docs.google.com/document/d/1noDVWTvTWBdYdweICPBwvwyt8QvX4KHl7j3XKNSg1nE/edit?usp=sharing