[PATCH] D154353: [DebugInfo][RemoveDIs] Implement behind-the-scenes debug-info maintenance in splice / moveBefore / insertBefore APIs

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 3 08:03:00 PDT 2023


jmorse created this revision.
jmorse added reviewers: StephenTozer, probinson, Orlando.
Herald added a subscriber: hiraditya.
Herald added a project: All.
jmorse requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is the "central" patch to the removing-debug-intrinsics project: it changes the instruction movement APIs (insert, move, splice) to interpret the "Head" bits we're attaching to BasicBlock::iterators, and updates debug-info records in the background to preserve the ordering of debug-info (which is in DPValue objects instead of dbg.values). The cost is the complexity of this patch, plus memory. The benefit is that LLVM developers can cease thinking about whether they're moving debug-info or not, because it'll happen behind the scenes.

To get an idea of what's going on, immediately skip to looking at the comment in BasicBlock::spliceDebugInfo. In dbg.value form, variable location information gets moved around automatically because it's an instruction, and it always stays in the right order. However, once converted into DPValue objects, we have to do this manually. The presence of the "head" bits on iterators indicates whether or not a transfer of instructions is intended to include the leading debug-info or not (in one scenario: the trailing debug-info). BasicBlock::splice now interprets those and moves DPValues around as appropriate. The range of transfers that can be described in splice() is explicitly enumerated in the unit test added, and there's a worked example in each scenario for clarity.

The rest of this patch applies the same reasoning in a variety of scenarios. When moveBefore (and it's siblings) are used to move instructions around, the caller has to indicate whether they intend for debug-info to move too (is it a "Preserving" call or not), and then the "Head" bits used to determine where debug-info moves to. Similar reasoning is needed for insertBefore.

Some utility methods are added to Instruction to allow examining whether an instruction has debug-info attached to it or not.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154353

Files:
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/IR/Instruction.h
  llvm/lib/IR/BasicBlock.cpp
  llvm/lib/IR/DebugProgramInstruction.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/unittests/IR/BasicBlockDbgInfoTest.cpp
  llvm/unittests/IR/CMakeLists.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154353.536767.patch
Type: text/x-patch
Size: 71122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230703/6ccb08f5/attachment.bin>


More information about the llvm-commits mailing list