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
Use = 0 in the header instead?