[PATCH] D46184: [BranchFolding] Salvage DBG_VALUE instructions from empty blocks

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 27 05:35:52 PDT 2018


bjope created this revision.
bjope added reviewers: debug-info, aprantl, rnk.

This patch will introduce copying of DBG_VALUE instructions
from an otherwise empty basic block to predecessor/successor
blocks in case the empty block is eliminated/bypassed. It
is currently only done in one identified situation in the
BranchFolding pass, before optimizing on empty block.
It can be seen as a light variant of the propagation done
by the LiveDebugValues pass, which unfortunately is executed
after the BranchFolding pass.

We only propagate (copy) DBG_VALUE instructions in a limited
number of situations:
 a) If the empty BB is the only predecessor of a successor

  we can copy the DBG_VALUE instruction to the beginning of
  the successor (because the DBG_VALUE instruction is always
  part of the flow between the blocks).

b) If the empty BB is the only successor of a predecessor

  we can copy the DBG_VALUE instruction to the end of the
  predecessor (because the DBG_VALUE instruction is always
  part of the flow between the blocks). In this case we add
  the DBG_VALUE just before the first terminator (assuming
  that the terminators do not impact the DBG_VALUE).

A future solution, to handle more situations, could perhaps
be to run the LiveDebugValues pass before branch folding?

This fix is related to PR37234. It is expected to resolve
the problem seen, when applied together with the fix in
SelectionDAG from here: https://reviews.llvm.org/D46129


Repository:
  rL LLVM

https://reviews.llvm.org/D46184

Files:
  lib/CodeGen/BranchFolding.cpp
  test/DebugInfo/X86/PR37234.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46184.144318.patch
Type: text/x-patch
Size: 8849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180427/33a5f995/attachment.bin>


More information about the llvm-commits mailing list