@@ -961,9 +961,13 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src,
961
961
// Detach the marker at Dest -- this lets us move the "====" DbgRecords
962
962
// around.
963
963
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 {
966
969
DestMarker->removeFromParent ();
970
+ }
967
971
}
968
972
969
973
// 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,
1005
1009
} else {
1006
1010
// Insert them right at the start of the range we moved, ahead of First
1007
1011
// 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.
1008
1016
DbgMarker *FirstMarker = createMarker (First);
1009
1017
FirstMarker->absorbDebugValues (*DestMarker, true );
1010
1018
}
1011
1019
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
- }
1024
1020
}
1025
1021
}
1026
1022
0 commit comments