Skip to content

Commit 14147ed

Browse files
committed
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
1 parent cfaeacd commit 14147ed

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5458,11 +5458,9 @@ bool CodeGenPrepare::splitBranchCondition(Function &F) {
54585458
DEBUG(dbgs() << "Before branch condition splitting\n"; BB.dump());
54595459

54605460
// Create a new BB.
5461-
auto *InsertBefore = std::next(Function::iterator(BB))
5462-
.getNodePtrUnchecked();
5463-
auto TmpBB = BasicBlock::Create(BB.getContext(),
5464-
BB.getName() + ".cond.split",
5465-
BB.getParent(), InsertBefore);
5461+
auto TmpBB =
5462+
BasicBlock::Create(BB.getContext(), BB.getName() + ".cond.split",
5463+
BB.getParent(), BB.getNextNode());
54665464

54675465
// Update original basic block by using the first condition directly by the
54685466
// branch instruction and removing the no longer needed and/or instruction.

lib/IR/BasicBlock.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,8 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
361361
assert(I != InstList.end() &&
362362
"Trying to get me to create degenerate basic block!");
363363

364-
BasicBlock *InsertBefore = std::next(Function::iterator(this))
365-
.getNodePtrUnchecked();
366-
BasicBlock *New = BasicBlock::Create(getContext(), BBName,
367-
getParent(), InsertBefore);
364+
BasicBlock *New = BasicBlock::Create(getContext(), BBName, getParent(),
365+
this->getNextNode());
368366

369367
// Save DebugLoc of split point before invalidating iterator.
370368
DebugLoc Loc = I->getDebugLoc();

0 commit comments

Comments
 (0)