[PATCH] D118449: [Inline][Cloning] Reliably remove unreachable blocks during cloning (PR53206)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 03:46:40 PST 2022


nikic created this revision.
nikic added reviewers: efriedma, rnk.
Herald added a subscriber: hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The pruning cloner already tries to remove unreachable blocks. The original cloning process will simplify instructions and constant terminators, and only clone blocks that are reachable at that point. However, phi nodes can only be simplified after everything has been cloned. For that reason, additional blocks may become unreachable after phi simplification.

The code does try to handle this as well, but only removes blocks that don't have predecessors. It misses unreachable cycles. This can cause issues if SEH exception handling code is part of an unreachable cycle, as the inliner is not prepared to deal with that.

This patch instead performs an explicit scan for reachable blocks, and drops everything else.

Fixes https://github.com/llvm/llvm-project/issues/53206.


https://reviews.llvm.org/D118449

Files:
  llvm/lib/Transforms/Utils/CloneFunction.cpp
  llvm/test/Transforms/Inline/pr53206.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118449.403956.patch
Type: text/x-patch
Size: 4313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220128/6d28b2fc/attachment.bin>


More information about the llvm-commits mailing list