Introduce fix-irreducible pass
authorSameer Sahasrabuddhe <sameer.sahasrabuddhe@amd.com>
Wed, 15 Apr 2020 09:35:51 +0000 (15:05 +0530)
committerSameer Sahasrabuddhe <sameer.sahasrabuddhe@amd.com>
Wed, 15 Apr 2020 09:35:51 +0000 (15:05 +0530)
commit8c11bc0cd06ffc18786a1a51ee5ce5b1cc4923f6
treec549b859bd4972148c0815efb78c1125d08a61d6
parent79d185c79271455c6b05c86ba422f40e70c7e970
Introduce fix-irreducible pass

An irreducible SCC is one which has multiple "header" blocks, i.e., blocks
with control-flow edges incident from outside the SCC. This pass converts an
irreducible SCC into a natural loop by introducing a single new header
block and redirecting all the edges on the original headers to this
new block.

This is a useful workaround for a limitation in the structurizer
which, which produces incorrect control flow in the presence of
irreducible regions. The AMDGPU backend provides an option to
enable this pass before the structurizer, which may eventually be
enabled by default.

Reviewed By: nhaehnle

Differential Revision: https://reviews.llvm.org/D77198

This restores commit 2ada8e2525dd2653f30c8696a27162a3b1647d66.

Originally reverted with commit 44e09b59b869a91bf47d76e8bc569d9ee91ad145.
14 files changed:
llvm/include/llvm/Analysis/LoopInfo.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/LinkAllPasses.h
llvm/include/llvm/Transforms/Utils.h
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/CMakeLists.txt
llvm/lib/Transforms/Utils/FixIrreducible.cpp [new file with mode: 0644]
llvm/lib/Transforms/Utils/Utils.cpp
llvm/test/Transforms/FixIrreducible/basic.ll [new file with mode: 0644]
llvm/test/Transforms/FixIrreducible/nested.ll [new file with mode: 0644]
llvm/test/Transforms/FixIrreducible/switch.ll [new file with mode: 0644]
llvm/test/Transforms/StructurizeCFG/workarounds/needs-fix-reducible.ll [new file with mode: 0644]
llvm/test/Transforms/StructurizeCFG/workarounds/needs-fr-ule.ll [new file with mode: 0644]