[RFC] Instruction API changes needed to eliminate debug intrinsics from IR

[Thanks Scott,]

Here’s an outline of how we’d like to move this forwards; we can put a lot of non-invasive changes in tree with zero impact on the rest of LLVM, which makes development easier for us. We’re continuing to iterate on the data-structures used for non-instruction debug-info, it’s at the point where -g compiles are a little faster (while still doing a lot of redundant work), more news on that in the future.

  1. We can fix a variety of debug-info-affects-codegen faults we’ve found in this process,
  2. Add iterator-accepting insertion handlers and utilities, for the most part this is only changing whether an iterator is dereferenced or getIterator is called on an instruction,
  3. Channel all block splicing through a single function (this has largely been done on main by others already),
  4. Use a specialised moveBefore method with the “moving debug-info” disposition at about 20 locations in LLVM

That’ll reduce the size of delta we have from ‘main’ to roughly 30 files, which is much easier to manage. Once we’ve got a Good ™ in-memory representation, we’ll make another proposal about those and:

  1. Add the relevant files and plumbing to the llvm/lib/IR directory,
  2. Add parallel implementations of the 15 to 20 places that directly update dbg.values today,
  3. Add the relevant bits to BasicBlock::iterator as mentioned above.

This will allow for more equivalence testing and experimentation by other developers, plus evaluation of the compile-time benefits. The final steps would be working out how to represent this information in textual IR and bitcode, plus update the 1000 tests containing dbg.values.

1 Like