Skip to content

Commit 341f02e

Browse files
author
git apple-llvm automerger
committed
Merge commit 'e1be8cf8723e' from llvm.org/release/19.x into stable/20240723
2 parents 55b16c4 + e1be8cf commit 341f02e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

llvm/lib/IR/BasicBlock.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -961,9 +961,13 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src,
961961
// Detach the marker at Dest -- this lets us move the "====" DbgRecords
962962
// around.
963963
DbgMarker *DestMarker = nullptr;
964-
if (Dest != end()) {
965-
if ((DestMarker = getMarker(Dest)))
964+
if ((DestMarker = getMarker(Dest))) {
965+
if (Dest == end()) {
966+
assert(DestMarker == getTrailingDbgRecords());
967+
deleteTrailingDbgRecords();
968+
} else {
966969
DestMarker->removeFromParent();
970+
}
967971
}
968972

969973
// If we're moving the tail range of DbgRecords (":::"), absorb them into the
@@ -1005,22 +1009,14 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src,
10051009
} else {
10061010
// Insert them right at the start of the range we moved, ahead of First
10071011
// and the "++++" DbgRecords.
1012+
// This also covers the rare circumstance where we insert at end(), and we
1013+
// did not generate the iterator with begin() / getFirstInsertionPt(),
1014+
// meaning any trailing debug-info at the end of the block would
1015+
// "normally" have been pushed in front of "First". We move it there now.
10081016
DbgMarker *FirstMarker = createMarker(First);
10091017
FirstMarker->absorbDebugValues(*DestMarker, true);
10101018
}
10111019
DestMarker->eraseFromParent();
1012-
} else if (Dest == end() && !InsertAtHead) {
1013-
// In the rare circumstance where we insert at end(), and we did not
1014-
// generate the iterator with begin() / getFirstInsertionPt(), it means
1015-
// any trailing debug-info at the end of the block would "normally" have
1016-
// been pushed in front of "First". Move it there now.
1017-
DbgMarker *TrailingDbgRecords = getTrailingDbgRecords();
1018-
if (TrailingDbgRecords) {
1019-
DbgMarker *FirstMarker = createMarker(First);
1020-
FirstMarker->absorbDebugValues(*TrailingDbgRecords, true);
1021-
TrailingDbgRecords->eraseFromParent();
1022-
deleteTrailingDbgRecords();
1023-
}
10241020
}
10251021
}
10261022

llvm/unittests/IR/BasicBlockDbgInfoTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ TEST(BasicBlockDbgInfoTest, SplitBasicBlockBefore) {
141141
Function *F = M->getFunction("func");
142142

143143
BasicBlock &BB = F->getEntryBlock();
144-
auto I = std::prev(BB.end(), 2);
144+
auto I = std::prev(BB.end(), 2); // store i32 2, ptr %1.
145145
BB.splitBasicBlockBefore(I, "before");
146146

147147
BasicBlock &BBBefore = F->getEntryBlock();
148-
auto I2 = std::prev(BBBefore.end(), 2);
148+
auto I2 = std::prev(BBBefore.end()); // br label %1 (new).
149149
ASSERT_TRUE(I2->hasDbgRecords());
150150
}
151151

0 commit comments

Comments
 (0)