Reapply "[func-sig-opts] Add SILFunction::findReturnBB to easily find the unique basic block containing a ReturnInst in a SILFunction."

This reverts commit r22933. Now with fixes so this actually compiles!

Swift SVN r22935
This commit is contained in:
Michael Gottesman
2014-10-25 00:14:39 +00:00
parent 7b774239d0
commit a0a66e3883
2 changed files with 21 additions and 5 deletions

View File

@@ -378,6 +378,26 @@ public:
getBlocks().splice(begin(), F->getBlocks());
}
/// Return the unique basic block containing a return inst if it
/// exists. Otherwise, returns end.
iterator findReturnBB() {
return std::find_if(begin(), end(),
[](const SILBasicBlock &BB) -> bool {
const TermInst *TI = BB.getTerminator();
return isa<ReturnInst>(TI);
});
}
/// Return the unique basic block containing a return inst if it
/// exists. Otherwise, returns end.
const_iterator findReturnBB() const {
return std::find_if(begin(), end(),
[](const SILBasicBlock &BB) -> bool {
const TermInst *TI = BB.getTerminator();
return isa<ReturnInst>(TI);
});
}
//===--------------------------------------------------------------------===//
// Miscellaneous
//===--------------------------------------------------------------------===//