47 #define DEBUG_TYPE "amdgpu-unify-divergent-exit-nodes" 51 class AMDGPUUnifyDivergentExitNodes :
public FunctionPass {
71 "Unify divergent function exit nodes",
false,
false)
77 void AMDGPUUnifyDivergentExitNodes::getAnalysisUsage(
AnalysisUsage &AU)
const{
106 while (!Stack.
empty()) {
112 if (Visited.
insert(Pred).second)
146 PN->addIncoming(BB->getTerminator()->getOperand(0), BB);
162 auto &PDT = getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();
163 if (PDT.getRoots().size() <= 1)
177 if (isa<ReturnInst>(BB->getTerminator())) {
179 ReturningBlocks.push_back(BB);
180 }
else if (isa<UnreachableInst>(BB->getTerminator())) {
183 }
else if (
BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator())) {
186 if (DummyReturnBB ==
nullptr) {
188 "DummyReturnBlock", &
F);
192 ReturningBlocks.push_back(DummyReturnBB);
195 if (BI->isUnconditional()) {
196 BasicBlock *LoopHeaderBB = BI->getSuccessor(0);
203 "TransitionBlock", &
F);
215 if (!UnreachableBlocks.
empty()) {
218 if (UnreachableBlocks.
size() == 1) {
219 UnreachableBlock = UnreachableBlocks.
front();
222 "UnifiedUnreachableBlock", &
F);
232 if (!ReturningBlocks.empty()) {
252 ReturningBlocks.push_back(UnreachableBlock);
257 if (ReturningBlocks.empty())
260 if (ReturningBlocks.size() == 1)
264 = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
void push_back(const T &Elt)
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
static bool isUniformlyReached(const LegacyDivergenceAnalysis &DA, BasicBlock &BB)
#define INITIALIZE_PASS_DEPENDENCY(depName)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
bool isVoidTy() const
Return true if this is 'void'.
static bool runOnFunction(Function &F, bool PostInlining)
Type * getReturnType() const
Returns the type of the ret val.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
Conditional or Unconditional Branch instruction.
char & BreakCriticalEdgesID
size_t size() const
size - Get the array size.
This function has undefined behavior.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
const InstListType & getInstList() const
Return the underlying instruction list container.
void removeFromParent()
Unlink 'this' from the containing function, but do not delete it.
INITIALIZE_PASS_BEGIN(AMDGPUUnifyDivergentExitNodes, DEBUG_TYPE, "Unify divergent function exit nodes", false, false) INITIALIZE_PASS_END(AMDGPUUnifyDivergentExitNodes
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
char & AMDGPUUnifyDivergentExitNodesID
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD T pop_back_val()
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
pred_range predecessors(BasicBlock *BB)
static ConstantInt * getTrue(LLVMContext &Context)
void push_back(pointer val)
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
iterator_range< typename GraphTraits< GraphType >::nodes_iterator > nodes(const GraphType &G)
LLVM_NODISCARD bool empty() const
SymbolTableList< BasicBlock >::iterator eraseFromParent()
Unlink 'this' from the containing function and delete it.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
bool isUniform(const Value *V) const
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI, const SimplifyCFGOptions &Options={}, SmallPtrSetImpl< BasicBlock *> *LoopHeaders=nullptr)
This function is used to do simplification of a CFG.
void initializeAMDGPUUnifyDivergentExitNodesPass(PassRegistry &)
static BasicBlock * unifyReturnBlockSet(Function &F, ArrayRef< BasicBlock *> ReturningBlocks, const TargetTransformInfo &TTI, StringRef Name)