[llvm] 7eafa5b - [KeyInstr] Fix #139070 for empty DebugLocs
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 06:55:12 PDT 2025
Author: Orlando Cazalet-Hyams
Date: 2025-05-08T14:55:05+01:00
New Revision: 7eafa5bdb78f371f3173d31df4479c8f7f23d8aa
URL: https://github.com/llvm/llvm-project/commit/7eafa5bdb78f371f3173d31df4479c8f7f23d8aa
DIFF: https://github.com/llvm/llvm-project/commit/7eafa5bdb78f371f3173d31df4479c8f7f23d8aa.diff
LOG: [KeyInstr] Fix #139070 for empty DebugLocs
Added:
Modified:
llvm/lib/IR/BasicBlock.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index aea07f4731e7d..d56f4d399ea52 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -612,7 +612,10 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName,
this->getNextNode());
// Save DebugLoc of split point before invalidating iterator.
- DebugLoc Loc = I->getStableDebugLoc()->getWithoutAtom();
+ DebugLoc Loc = I->getStableDebugLoc();
+ if (Loc)
+ Loc = Loc->getWithoutAtom();
+
// Move all of the specified instructions from the original basic block into
// the new basic block.
New->splice(New->end(), this, I, end());
@@ -641,7 +644,10 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
BasicBlock *New = BasicBlock::Create(getContext(), BBName, getParent(), this);
// Save DebugLoc of split point before invalidating iterator.
- DebugLoc Loc = I->getDebugLoc()->getWithoutAtom();
+ DebugLoc Loc = I->getDebugLoc();
+ if (Loc)
+ Loc = Loc->getWithoutAtom();
+
// Move all of the specified instructions from the original basic block into
// the new basic block.
New->splice(New->end(), this, begin(), I);
More information about the llvm-commits
mailing list