diff options
author | dim <dim@FreeBSD.org> | 2015-12-30 13:13:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-12-30 13:13:10 +0000 |
commit | 9b5bf5c4f53d65d6a48722d7410ed7cb15f5ba3a (patch) | |
tree | b466a4817f79516eb1df8eae92bccf62ecc84003 /contrib/llvm/lib/IR/BasicBlock.cpp | |
parent | f09a28d1de99fda4f5517fb12670fc36552f4927 (diff) | |
parent | e194cd6d03d91631334d9d5e55b506036f423cc8 (diff) | |
download | FreeBSD-src-9b5bf5c4f53d65d6a48722d7410ed7cb15f5ba3a.zip FreeBSD-src-9b5bf5c4f53d65d6a48722d7410ed7cb15f5ba3a.tar.gz |
Update llvm to trunk r256633.
Diffstat (limited to 'contrib/llvm/lib/IR/BasicBlock.cpp')
-rw-r--r-- | contrib/llvm/lib/IR/BasicBlock.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/contrib/llvm/lib/IR/BasicBlock.cpp b/contrib/llvm/lib/IR/BasicBlock.cpp index 0a04494..f61276f 100644 --- a/contrib/llvm/lib/IR/BasicBlock.cpp +++ b/contrib/llvm/lib/IR/BasicBlock.cpp @@ -21,6 +21,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Type.h" #include <algorithm> + using namespace llvm; ValueSymbolTable *BasicBlock::getValueSymbolTable() { @@ -35,8 +36,7 @@ LLVMContext &BasicBlock::getContext() const { // Explicit instantiation of SymbolTableListTraits since some of the methods // are not in the public header file... -template class llvm::SymbolTableListTraits<Instruction, BasicBlock>; - +template class llvm::SymbolTableListTraits<Instruction>; BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent, BasicBlock *InsertBefore) @@ -56,7 +56,7 @@ void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) { assert(!Parent && "Already has a parent"); if (InsertBefore) - NewParent->getBasicBlockList().insert(InsertBefore, this); + NewParent->getBasicBlockList().insert(InsertBefore->getIterator(), this); else NewParent->getBasicBlockList().push_back(this); } @@ -91,26 +91,26 @@ void BasicBlock::setParent(Function *parent) { } void BasicBlock::removeFromParent() { - getParent()->getBasicBlockList().remove(this); + getParent()->getBasicBlockList().remove(getIterator()); } iplist<BasicBlock>::iterator BasicBlock::eraseFromParent() { - return getParent()->getBasicBlockList().erase(this); + return getParent()->getBasicBlockList().erase(getIterator()); } /// Unlink this basic block from its current function and /// insert it into the function that MovePos lives in, right before MovePos. void BasicBlock::moveBefore(BasicBlock *MovePos) { - MovePos->getParent()->getBasicBlockList().splice(MovePos, - getParent()->getBasicBlockList(), this); + MovePos->getParent()->getBasicBlockList().splice( + MovePos->getIterator(), getParent()->getBasicBlockList(), getIterator()); } /// Unlink this basic block from its current function and /// insert it into the function that MovePos lives in, right after MovePos. void BasicBlock::moveAfter(BasicBlock *MovePos) { - Function::iterator I = MovePos; - MovePos->getParent()->getBasicBlockList().splice(++I, - getParent()->getBasicBlockList(), this); + MovePos->getParent()->getBasicBlockList().splice( + ++MovePos->getIterator(), getParent()->getBasicBlockList(), + getIterator()); } const Module *BasicBlock::getModule() const { @@ -196,8 +196,8 @@ BasicBlock::iterator BasicBlock::getFirstInsertionPt() { if (!FirstNonPHI) return end(); - iterator InsertPt = FirstNonPHI; - if (isa<LandingPadInst>(InsertPt)) ++InsertPt; + iterator InsertPt = FirstNonPHI->getIterator(); + if (InsertPt->isEHPad()) ++InsertPt; return InsertPt; } @@ -245,12 +245,12 @@ BasicBlock *BasicBlock::getSingleSuccessor() { BasicBlock *BasicBlock::getUniqueSuccessor() { succ_iterator SI = succ_begin(this), E = succ_end(this); - if (SI == E) return NULL; // No successors + if (SI == E) return nullptr; // No successors BasicBlock *SuccBB = *SI; ++SI; for (;SI != E; ++SI) { if (*SI != SuccBB) - return NULL; + return nullptr; // The same successor appears multiple times in the successor list. // This is OK. } @@ -333,6 +333,17 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, } } +bool BasicBlock::canSplitPredecessors() const { + const Instruction *FirstNonPHI = getFirstNonPHI(); + if (isa<LandingPadInst>(FirstNonPHI)) + return true; + // This is perhaps a little conservative because constructs like + // CleanupBlockInst are pretty easy to split. However, SplitBlockPredecessors + // cannot handle such things just yet. + if (FirstNonPHI->isEHPad()) + return false; + return true; +} /// This splits a basic block into two at the specified /// instruction. Note that all instructions BEFORE the specified iterator stay @@ -393,8 +404,7 @@ void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) { // Cope with being called on a BasicBlock that doesn't have a terminator // yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this. return; - for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) { - BasicBlock *Succ = TI->getSuccessor(i); + for (BasicBlock *Succ : TI->successors()) { // N.B. Succ might not be a complete BasicBlock, so don't assume // that it ends with a non-phi instruction. for (iterator II = Succ->begin(), IE = Succ->end(); II != IE; ++II) { |