[BBUtils] Don't add 'then' block to a loop if it's terminated with unreachable
authorDmitry Makogon <d.makogon@g.nsu.ru>
Thu, 8 Jun 2023 11:56:18 +0000 (18:56 +0700)
committerDmitry Makogon <d.makogon@g.nsu.ru>
Mon, 19 Jun 2023 13:24:30 +0000 (20:24 +0700)
commitd46d9689f7c3fe16010cd07761858a6392239b3f
tree180c5fdc1db0dfb58f728e1ef29509c27b0ff45c
parent9d4c1be8b0793ee94e0906e4ff40d1ff325470de
[BBUtils] Don't add 'then' block to a loop if it's terminated with unreachable

SplitBlockAndInsertIfThen utility creates two new blocks,
they're called ThenBlock and Tail (true and false destinations of a conditional
branch correspondingly). The function has a bool parameter Unreachable,
and if it's set, then ThenBlock is terminated with an unreachable.
At the end of the function the new blocks are added to the loop of the split
block. However, in case ThenBlock is terminated with an unreachable,
it cannot belong to any loop.

Differential Revision: https://reviews.llvm.org/D152434
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/test/Transforms/SimpleLoopUnswitch/guards.ll
llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll