ADT: Stop using getNodePtrUnchecked on end() iterators

Stop using `getNodePtrUnchecked()` when building IR.  Eventually a
dereference will be required to get at the downcast node, since the
iterator will only store an `ilist_node_base` of some sort.

This should have no functionality change for now, but is a path towards
removing some more UB from ilist.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261495 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2016-02-21 19:52:15 +00:00
parent cfaeacdafb
commit 14147eda61
2 changed files with 5 additions and 9 deletions

View File

@ -5458,11 +5458,9 @@ bool CodeGenPrepare::splitBranchCondition(Function &F) {
DEBUG(dbgs() << "Before branch condition splitting\n"; BB.dump()); DEBUG(dbgs() << "Before branch condition splitting\n"; BB.dump());
// Create a new BB. // Create a new BB.
auto *InsertBefore = std::next(Function::iterator(BB)) auto TmpBB =
.getNodePtrUnchecked(); BasicBlock::Create(BB.getContext(), BB.getName() + ".cond.split",
auto TmpBB = BasicBlock::Create(BB.getContext(), BB.getParent(), BB.getNextNode());
BB.getName() + ".cond.split",
BB.getParent(), InsertBefore);
// Update original basic block by using the first condition directly by the // Update original basic block by using the first condition directly by the
// branch instruction and removing the no longer needed and/or instruction. // branch instruction and removing the no longer needed and/or instruction.

View File

@ -361,10 +361,8 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
assert(I != InstList.end() && assert(I != InstList.end() &&
"Trying to get me to create degenerate basic block!"); "Trying to get me to create degenerate basic block!");
BasicBlock *InsertBefore = std::next(Function::iterator(this)) BasicBlock *New = BasicBlock::Create(getContext(), BBName, getParent(),
.getNodePtrUnchecked(); this->getNextNode());
BasicBlock *New = BasicBlock::Create(getContext(), BBName,
getParent(), InsertBefore);
// Save DebugLoc of split point before invalidating iterator. // Save DebugLoc of split point before invalidating iterator.
DebugLoc Loc = I->getDebugLoc(); DebugLoc Loc = I->getDebugLoc();