Page MenuHomePhabricator

[DebugInstrRef][7/9] NFC: Separate collection of machine/variable values
AcceptedPublic

Authored by jmorse on Aug 11 2020, 10:56 AM.

Details

Reviewers
aprantl
Group Reviewers
debug-info
Summary

This patch adjusts _when_ something happens in LiveDebugValues / InstrRefBasedLDV, to make it more amenable to dealing with DBG_INSTR_REF instructions. There's no functional change.

In the current base InstrRefBasedLDV implementation, we collect the machine value-number transfer function for blocks at the same time as the variable-value transfer function. After solving machine value numbers, the variable-value transfer function is updated so that DBG_VALUEs of live-in registers have the correct value. The same would need to be done for DBG_INSTR_REFs, to connect instruction-references with machine value numbers.

Rather than writing more code for that, this patch makes things slightly simpler:

  • We collect the (machine-value-number) transfer function and solve for machine value numbers,
  • Then step through the MachineInstrs again collecting the variable value transfer function.

The change is that linking up variable values with how they're defined (as being in a register, or as an instruction reference) is done as we step through the MachineInstrs, instead of on-the-fly. This is slower (in terms of compile time performance) but makes the next patch much easier to understand.

Diff Detail

Event Timeline

jmorse created this revision.Aug 11 2020, 10:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2020, 10:56 AM
aprantl added inline comments.
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
3043

can this be for (MachineBasicBlock &MBB : OrderToBB) ?

3052

What is CurInst used for?

jmorse updated this revision to Diff 285023.Aug 12 2020, 2:46 AM
jmorse marked an inline comment as done.

Switch a loop to being ranged-based.

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
3043

Yup (ish), updated to use a range based loop.

3052

Because I'm identifying each value by the instruction defining it, each instruction needs a unique number which I derive from its block number and position within that block. See the ValueIDNum class in D83047, every value number is a tuple {block-number, instruction-number, register-or-spill-number}. In this loop we have to step through those numbers, with the "current" block / instruction number in CurBB / CurInst.

I guess this is easily replaceable by passing those numbers to "process" and its helpers rather than storing it in the object, and that would closer match what the VarLoc LiveDebugValues does. I'll add this to a list of things to polish, unless it's important for this patch.

aprantl accepted this revision.Aug 19 2020, 8:45 AM
This revision is now accepted and ready to land.Aug 19 2020, 8:45 AM