Skip to content

Commit 7eafa5b

Browse files
committed
[KeyInstr] Fix #139070 for empty DebugLocs
1 parent 6e654ca commit 7eafa5b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/IR/BasicBlock.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,10 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName,
612612
this->getNextNode());
613613

614614
// Save DebugLoc of split point before invalidating iterator.
615-
DebugLoc Loc = I->getStableDebugLoc()->getWithoutAtom();
615+
DebugLoc Loc = I->getStableDebugLoc();
616+
if (Loc)
617+
Loc = Loc->getWithoutAtom();
618+
616619
// Move all of the specified instructions from the original basic block into
617620
// the new basic block.
618621
New->splice(New->end(), this, I, end());
@@ -641,7 +644,10 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
641644

642645
BasicBlock *New = BasicBlock::Create(getContext(), BBName, getParent(), this);
643646
// Save DebugLoc of split point before invalidating iterator.
644-
DebugLoc Loc = I->getDebugLoc()->getWithoutAtom();
647+
DebugLoc Loc = I->getDebugLoc();
648+
if (Loc)
649+
Loc = Loc->getWithoutAtom();
650+
645651
// Move all of the specified instructions from the original basic block into
646652
// the new basic block.
647653
New->splice(New->end(), this, begin(), I);

0 commit comments

Comments
 (0)