[PATCH] D124398: [DebugInfo] Don't skip deletion of dead BasicBlocks because of debug-info instructions

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 09:25:53 PDT 2022


jmorse created this revision.
jmorse added reviewers: Orlando, StephenTozer, probinson.
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 patch fixes a debug-info-changes-codegen problem, reported here:

  https://github.com/llvm/llvm-project/issues/50525

Where the unreachableblockelim pass wouldn't delete an empty unreachable block due to the presence of debug-info instructions. The solution, as ever, is to ignore the debug-info instructions. This particular function is different, in that it steps through the block backwards, and so existing filter functions aren't suitable as they all expect forward iterators. Thus, a help lambda is required.

The most worry part here is replacing a line that is:

  BB->getInsnlist().pop_back()

With Instruction::eraseFromParent on a non-back instruction. I think this is fine: it's just that over time, the set of helper functions that LLVM uses has changed, and this line hasn't been changed since at least 2008: https://github.com/llvm/llvm-project/commit/bcc904a67c2f77b6a619d8ec9370af02e3a5ce02


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124398

Files:
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/test/DebugInfo/Generic/unreachable-block-elim.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124398.424933.patch
Type: text/x-patch
Size: 4845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220425/47e5a98c/attachment.bin>


More information about the llvm-commits mailing list