This is an archive of the discontinued LLVM Phabricator instance.

[DebugInstrRef][1/9] Initial fields and instruction for instruction-referencing variable locations
ClosedPublic

Authored by jmorse on Aug 11 2020, 8:45 AM.

Details

Summary

This is a series of patches adding basic instruction-referencing functionality to debug instructions, as described in this RFC [0]. All of this work hinges on the stack of LiveDebugValues work at D83046 which is getting reviewed: it may or may not finish anytime soon, but I've uploaded these patches for further transparency and reducing bus factor.

This patch series allows DBG_INSTR_REF instructions to reference instructions that are (initially) in the same block as the corresponding dbg.value; two other series will deal with:

  • PHIs, and their passage through regalloc,
  • COPYs.

This patch itself doesn't add any code, instead it adds some data structure fields: each MachineInstr now gets an instruction number field, and a corresponding field in MachineFunction records the "next" instruction number. The idea behind this is that each MachineInstr is going to carry around a unique identifier that DBG_INSTR_REFs refer to. This is the core part of the "lets refer to instructions" idea. Each DBG_INSTR_REF instruction has the format:

DBG_INSTR_REF inst-num-imm, operand-num-imm, !DILocalVariable..., !DIExpression...

i.e., the first operand identifies an instruction number and an operand within that instruction. This means we can identify values by the place that they're defined, but an important design decision is that there's no direct connection between the two. It's inefficient to identify the instruction from the DBG_INSTR_REF, and vice versa. This may (or may not) be worthy of discussion.

[0] http://lists.llvm.org/pipermail/llvm-dev/2020-February/139440.html

Diff Detail

Event Timeline

jmorse created this revision.Aug 11 2020, 8:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2020, 8:45 AM
jmorse requested review of this revision.Aug 11 2020, 8:45 AM
aprantl accepted this revision.Aug 19 2020, 8:36 AM
aprantl added a subscriber: aprantl.

Mechanically this looks fine — would be good for others to chime in whether we have consensus over doing this change though.

llvm/lib/CodeGen/MachineInstr.cpp
138

Use = 0 in the header instead?

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

Oh, one important thing: Can you add a section to the .rst documentation with a MIR example that explains what a DBG_VALUE_REF is / what it's used for, etc?

This revision was landed with ongoing or failed builds.Sep 14 2020, 2:20 AM
This revision was automatically updated to reflect the committed changes.

Oh, one important thing: Can you add a section to the .rst documentation with a MIR example that explains what a DBG_VALUE_REF is / what it's used for, etc?

Curses, this fell out of my working-set before commiting; I'll cook that up now.