Completion of MandatoryInlining pass: recursive inlining, multiple basic blocks, and diagnosis of circular inlining.

Swift SVN r7242
This commit is contained in:
Stephen Lin
2013-08-14 22:30:21 +00:00
parent 12e9086893
commit 4ae68cd72f
8 changed files with 572 additions and 104 deletions

View File

@@ -14,9 +14,12 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/STLExtras.h"
#include "swift/SIL/SILBasicBlock.h"
#include "swift/SIL/SILArgument.h"
#include "swift/SIL/SILFunction.h"
#include "swift/SIL/SILInstruction.h"
#include "swift/SIL/SILModule.h"
using namespace swift;
//===----------------------------------------------------------------------===//
@@ -69,3 +72,24 @@ const SILModule *SILBasicBlock::getModule() const {
void SILBasicBlock::eraseFromParent() {
getParent()->getBlocks().erase(this);
}
/// splitBasicBlock - This splits a basic block into two at the specified
/// instruction. Note that all instructions BEFORE the specified iterator stay
/// as part of the original basic block. If CreateBranch is true, an
/// unconditional branch is added from the old basic block to the new basic
/// block, otherwise the old basic block is left without a terminator.
SILBasicBlock *SILBasicBlock::splitBasicBlock(iterator I, bool CreateBranch,
SILLocation BranchLoc) {
SILBasicBlock *New = new (Parent->getModule()) SILBasicBlock(Parent);
SILFunction::iterator Where = llvm::next(SILFunction::iterator(this));
SILFunction::iterator First = SILFunction::iterator(New);
if (Where != First)
Parent->getBlocks().splice(Where, Parent->getBlocks(), First);
// Move all of the specified instructions from the original basic block into
// the new basic block.
New->getInsts().splice(New->end(), this->getInsts(), I, end());
if (CreateBranch)
getInsts().insert(getInsts().end(),
BranchInst::create(BranchLoc, New, *getParent()));
return New;
}