Skip to content

Commit 61b2198

Browse files
committed
[KeyInstr] Fix llvm#139070 for empty DebugLocs
1 parent 8b5d884 commit 61b2198

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
@@ -609,7 +609,10 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName,
609609
this->getNextNode());
610610

611611
// Save DebugLoc of split point before invalidating iterator.
612-
DebugLoc Loc = I->getStableDebugLoc()->getWithoutAtom();
612+
DebugLoc Loc = I->getStableDebugLoc();
613+
if (Loc)
614+
Loc = Loc->getWithoutAtom();
615+
613616
// Move all of the specified instructions from the original basic block into
614617
// the new basic block.
615618
New->splice(New->end(), this, I, end());
@@ -638,7 +641,10 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
638641

639642
BasicBlock *New = BasicBlock::Create(getContext(), BBName, getParent(), this);
640643
// Save DebugLoc of split point before invalidating iterator.
641-
DebugLoc Loc = I->getDebugLoc()->getWithoutAtom();
644+
DebugLoc Loc = I->getDebugLoc();
645+
if (Loc)
646+
Loc = Loc->getWithoutAtom();
647+
642648
// Move all of the specified instructions from the original basic block into
643649
// the new basic block.
644650
New->splice(New->end(), this, begin(), I);

0 commit comments

Comments
 (0)