Page MenuHomePhabricator

Multiple Locations support for Debug Variables
Needs ReviewPublic

Authored by tvvikram on Aug 12 2015, 12:33 PM.

Details

Summary

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

Diff Detail

Event Timeline

tvvikram updated this revision to Diff 31970.Aug 12 2015, 12:33 PM
tvvikram retitled this revision from to Multiple Locations support for Debug Variables.
tvvikram updated this object.
tvvikram added a parent revision: D11933: Extending debug ranges.
tvvikram updated this object.Aug 12 2015, 12:37 PM
tvvikram added inline comments.Aug 12 2015, 12:48 PM
lib/CodeGen/DebugValueFixup.cpp
1 ↗(On Diff #31970)

Yet to be renamed. Does "ExtendDebugValueRangeAndLocation.cpp" sound okay? Please suggest.

tvvikram updated this revision to Diff 32794.Aug 20 2015, 9:56 PM
This comment was removed by tvvikram.
tvvikram updated this revision to Diff 32809.Aug 21 2015, 3:12 AM

Please ignore all the previous patches in this review.

This is an incremental patch over extending debug ranges - http://reviews.llvm.org/D11933. Please apply the patch from that review first. If a full diff (i.e. including the patch from D11933 review) is needed, please let me know; I will upload a full diff.

Incremental changes:
a. Provide infrastructure to handle multiple locations:

  • PreserveDbgValLoc flag addition
  • Interpreting the flag in DbgValueHistoryCalculator code and buildLocationLists() routine in DwarfDebug.cpp.

b. Infer multiple locations from copies in ExtendDebugRangeLocation.cpp
c. Fix test cases. Add dwarf and .mir test case for multiple location.

Thank you!

bjope added a subscriber: bjope.Sep 5 2017, 1:43 PM