[PATCH] D95463: Avoid redundant or out-of-order debug value sinking in InstCombine

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 26 11:07:15 PST 2021


StephenTozer created this revision.
StephenTozer added reviewers: avl, jmorse, bjope, aprantl.
StephenTozer added a project: debug-info.
Herald added subscribers: mgrang, hiraditya.
StephenTozer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch modifies `TryToSinkInstruction` in the InstCombine pass, to prevent redundant debug intrinsics from being produced, and also prevent the intrinsics from being emitted in an incorrect order. It does this by ensuring that when this pass sinks an instruction and creates clones of the debug intrinsics that use that instruction, it inserts those debug intrinsics in their original order, and only inserts the last debug intrinsic for each variable in the Instruction's block.

This patch was created to deal with an issue found while testing another patch (D94631 <https://reviews.llvm.org/D94631>) in which repeated sinking of instructions across a very large number of basic blocks resulted in a cascading mass of debug intrinsics as each sink clones each previous intrinsic as well as any new ones in the current basic block. For one of the clang 3.4 source files, this resulted in an LL file 14gb in size after optimizations; this patch reduces the resulting file to 5mb. Although this is a very extreme case, it is quite likely that this problem is occuring on a smaller scale for other large source files - large switches seem particularly susceptible (in this generated by `CodeEmitterGenerator` using TableGen).

Note that as redundant debug intrinsics will not be emitted in the final debug info, this patch should not have any actual effect on the size of debug info produced; it should however improve correctness in cases where debug intrinsics were being emitted out-of-order (causing old debug values to overwrite new ones), and has a positive effect on compile time and memory usage in cases where this issue occurs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95463

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/debuginfo-sink.ll
  llvm/test/Transforms/InstCombine/debuginfo_add.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95463.319344.patch
Type: text/x-patch
Size: 5407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210126/e28c83b0/attachment.bin>


More information about the llvm-commits mailing list