Page MenuHomePhabricator

[DebugInstrRef][8/9] Convert DBG_INSTR_REFs into variable locations
ClosedPublic

Authored by jmorse on Aug 11 2020, 12:48 PM.

Details

Summary

Handle DBG_INSTR_REF instructions in LiveDebugValues, to determine and propagate variable locations. The logic is fairly straight forwards:

  • Collect a map of debug-instruction-number to the machine value numbers generated in the first walk through the function,
  • When building the variable value transfer function and we see a DBG_INSTR_REF, look up the instruction it refers to, and pick the machine value number it generates,
  • That's it; the rest of LiveDebugValues continues as normal.

Reviewing this change may be sticky, as it depends on what route we take with reviewing D83047.

Awkwardly, there are two kinds of instruction numbering happening here: the offset into the block (which is how machine value numbers are determined), and the numbers that we label instructions with when generating DBG_INSTR_REFs. Suggestions on naming them most welcome, I haven't come up with anything good yet.

Practically, the map above isn't to a set of value numbers, it's to a MachineInstr and its offset into its block. One can determine the machine value number it generates at a particular operand using that information.

I've also restructured the TransferTracker redefVar code a little, to separate some DBG_VALUE specific operations into its own method. The changes around redefVar should be largely NFC, while allowing DBG_INSTR_REFs to specify a value number rather than just a location.

Diff Detail

Event Timeline

jmorse created this revision.Aug 11 2020, 12:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2020, 12:48 PM
aprantl added inline comments.
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
919

???

1092–1097

We don't use curly braces for single statements.

jmorse updated this revision to Diff 287042.Aug 21 2020, 8:35 AM

Remove some needless comments and some needless curly braces.

jmorse marked 2 inline comments as done.Aug 21 2020, 8:37 AM
jmorse added inline comments.
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
919

The overlapping fragments comment was a reminder to myself that I hadn't implemented support for it yet; I guess it isn't helpful being left in the code.

(It won't be forgotten in the future as there's a test for overlapping fragments in-tree already).

aprantl added inline comments.Aug 21 2020, 1:11 PM
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
1632

if (!Tracker)

return true;
jmorse updated this revision to Diff 287091.Aug 21 2020, 1:17 PM
jmorse marked an inline comment as done.

Early-exit to avoid un-necessary indentation.

jmorse marked an inline comment as done.Aug 21 2020, 1:18 PM
aprantl accepted this revision.Aug 21 2020, 2:28 PM
This revision is now accepted and ready to land.Aug 21 2020, 2:28 PM