[AMDGPU] Unify uniform return and divergent unreachable blocks
authorBrendon Cahoon <brendon.cahoon@amd.com>
Thu, 27 Oct 2022 21:27:50 +0000 (16:27 -0500)
committerBrendon Cahoon <brendon.cahoon@amd.com>
Tue, 29 Nov 2022 19:25:56 +0000 (13:25 -0600)
commitb32a5666a8ee5e1ce00918f9f2835b29973f6f64
tree6aa85732dac76a0d10bf963e52cc556b41261331
parent2166d9529a60d1cdedb733d2e4134c971f0969ec
[AMDGPU] Unify uniform return and divergent unreachable blocks

This patch fixes a "failed to annotate CFG" error in
SIAnnotateControlFlow. The problem occurs when there are
divergent and uniform unreachable/return blocks in the same
region. In this case, AMDGPUUnifyDivergentExitNodes does not
create a unified block so the region contains multiple exits.

StructurizeCFG does not work properly when there are multiple
exits, so the neccessary CFG transformations do not occur along
divergent control flow. Subsequently, SIAnnotateControlFlow
processes the path to the divergent exit block, but may only
partially process blocks along a unform control flow path to
another exit block.

This patch fixes the bug by creating a single exit block when
there is a divergent exit block in the function.

Differential revision: https://reviews.llvm.org/D136892
llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/bool-legalization.ll
llvm/test/CodeGen/AMDGPU/exec-mask-opt-cannot-create-empty-or-backward-segment.ll
llvm/test/CodeGen/AMDGPU/si-unify-exit-return-unreachable.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/skip-if-dead.ll
llvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll