mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Completion of MandatoryInlining pass: recursive inlining, multiple basic blocks, and diagnosis of circular inlining.
Swift SVN r7242
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user