32 "Unify function exit nodes",
false,
false)
49 std::vector<BasicBlock *> UnreachableBlocks;
52 if (isa<UnreachableInst>(
I.getTerminator()))
53 UnreachableBlocks.push_back(&
I);
55 if (UnreachableBlocks.size() <= 1)
63 BB->back().eraseFromParent();
71 std::vector<BasicBlock *> ReturningBlocks;
74 if (isa<ReturnInst>(
I.getTerminator()))
75 ReturningBlocks.push_back(&
I);
77 if (ReturningBlocks.size() <= 1)
84 "UnifiedReturnBlock", &
F);
87 if (
F.getReturnType()->isVoidTy()) {
103 PN->
addIncoming(BB->getTerminator()->getOperand(0), BB);
105 BB->back().eraseFromParent();
117 bool Changed =
false;
118 Changed |= unifyUnreachableBlocks(
F);
119 Changed |= unifyReturnBlocks(
F);
125 bool Changed =
false;
126 Changed |= unifyUnreachableBlocks(
F);
127 Changed |= unifyReturnBlocks(
F);
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
A container for analyses that lazily runs them and caches their results.
Represent the analysis usage information of a pass.
AnalysisUsage & addPreservedID(const void *ID)
LLVM Basic Block Representation.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
FunctionPass class - This class is used to implement most global optimizations.
SymbolTableList< Instruction >::iterator insertInto(BasicBlock *ParentBB, SymbolTableList< Instruction >::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
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...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Pass interface - Implemented by all 'passes'.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
UnifyFunctionExitNodesLegacyPass()
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This function has undefined behavior.
This is an optimization pass for GlobalISel generic memory operations.
Pass * createUnifyFunctionExitNodesPass()
void initializeUnifyFunctionExitNodesLegacyPassPass(PassRegistry &)
char & BreakCriticalEdgesID