[SimplifyCFG] Redirect switch cases that lead to UB into an unreachable block
authorMax Kazantsev <mkazantsev@azul.com>
Tue, 21 Sep 2021 03:22:40 +0000 (10:22 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Tue, 21 Sep 2021 03:45:19 +0000 (10:45 +0700)
commit073b254cffeffdef36ffbee0c9afdc0da9cd6ac3
treebfd85651929456e24d15afe70c4e60bc7debeafd
parentcad9f98a2ad98fecf663e9ce39502b8e43676fc9
[SimplifyCFG] Redirect switch cases that lead to UB into an unreachable block

When following a case of a switch instruction is guaranteed to lead to
UB, we can safely break these edges and redirect those cases into a newly
created unreachable block. As result, CFG will become simpler and we can
remove some of Phi inputs to make further analyzes easier.

Patch by Dmitry Bakunevich!

Differential Revision: https://reviews.llvm.org/D109428
Reviewed By: lebedev.ri
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/CodeGen/AArch64/arm64-ccmp.ll
llvm/test/Transforms/SimplifyCFG/switch_ub.ll