37 lines · c
1//===- AMDGPUUnifyDivergentExitNodes.h ------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This is a variant of the UnifyFunctionExitNodes pass. Rather than ensuring10// there is at most one ret and one unreachable instruction, it ensures there is11// at most one divergent exiting block.12//13// StructurizeCFG can't deal with multi-exit regions formed by branches to14// multiple return nodes. It is not desirable to structurize regions with15// uniform branches, so unifying those to the same return block as divergent16// branches inhibits use of scalar branching. It still can't deal with the case17// where one branch goes to return, and one unreachable. Replace unreachable in18// this case with a return.19//20//===----------------------------------------------------------------------===//21 22#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUUNIFYDIVERGENTEXITNODES_H23#define LLVM_LIB_TARGET_AMDGPU_AMDGPUUNIFYDIVERGENTEXITNODES_H24 25#include "AMDGPU.h"26 27namespace llvm {28class AMDGPUUnifyDivergentExitNodesPass29 : public PassInfoMixin<AMDGPUUnifyDivergentExitNodesPass> {30public:31 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);32};33 34} // end namespace llvm35 36#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUUNIFYDIVERGENTEXITNODES_H37