Go to the documentation of this file.
32 "Unify function exit nodes",
false,
false)
48 bool unifyUnreachableBlocks(
Function &
F) {
49 std::vector<BasicBlock *> UnreachableBlocks;
52 if (isa<UnreachableInst>(
I.getTerminator()))
53 UnreachableBlocks.push_back(&
I);
55 if (UnreachableBlocks.size() <= 1)
63 BB->getInstList().pop_back();
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()) {
105 BB->getInstList().pop_back();
117 bool Changed =
false;
118 Changed |= unifyUnreachableBlocks(
F);
119 Changed |= unifyReturnBlocks(
F);
125 bool Changed =
false;
126 Changed |= unifyUnreachableBlocks(
F);
127 Changed |= unifyReturnBlocks(
F);
A set of analyses that are preserved following a run of a transformation pass.
This is an optimization pass for GlobalISel generic memory operations.
void initializeUnifyFunctionExitNodesLegacyPassPass(PassRegistry &)
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
LLVM Basic Block Representation.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
INITIALIZE_PASS(UnifyFunctionExitNodesLegacyPass, "mergereturn", "Unify function exit nodes", false, false) Pass *llvm
UnifyFunctionExitNodesLegacyPass()
Represent the analysis usage information of a pass.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
AnalysisUsage & addPreservedID(const void *ID)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Pass * createUnifyFunctionExitNodesPass()
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
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 ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *InsertBefore=nullptr)
char & BreakCriticalEdgesID
const InstListType & getInstList() const
Return the underlying instruction list container.
Pass interface - Implemented by all 'passes'.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
This function has undefined behavior.