Skip to content

Commit 1ce8753

Browse files
authored
Merge pull request #9947 from adrian-prantl/cleanup
2 parents f07337e + 5e16173 commit 1ce8753

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,8 +1647,7 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) {
16471647
bool InCleanupBlock = false;
16481648
bool KeepCurrentLocation = false;
16491649

1650-
for (auto InsnIter = BB->begin(); InsnIter != BB->end(); ++InsnIter) {
1651-
auto &I = *InsnIter;
1650+
for (auto &I : *BB) {
16521651
if (IGM.DebugInfo) {
16531652
// Set the debug info location for I, if applicable.
16541653
SILLocation ILoc = I.getLoc();
@@ -1664,7 +1663,7 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) {
16641663
InCleanupBlock = true;
16651664
// Scan ahead to see if this is the final cleanup block in
16661665
// this basic block.
1667-
auto It = InsnIter;
1666+
auto It = I.getIterator();
16681667
do ++It; while (It != BB->end() &&
16691668
It->getLoc().is<CleanupLocation>());
16701669
// We are still in the middle of a basic block?
@@ -1694,9 +1693,14 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) {
16941693
// Set the builder's debug location.
16951694
if (DS && !KeepCurrentLocation)
16961695
IGM.DebugInfo->setCurrentLoc(Builder, DS, ILoc);
1697-
else
1696+
else {
1697+
// Reuse the last scope for an easier-to-read line table.
1698+
auto Prev = --I.getIterator();
1699+
if (Prev != BB->end())
1700+
DS = Prev->getDebugScope();
16981701
// Use an artificial (line 0) location.
16991702
IGM.DebugInfo->setCurrentLoc(Builder, DS);
1703+
}
17001704

17011705
if (isa<TermInst>(&I))
17021706
emitDebugVariableRangeExtension(BB);

0 commit comments

Comments
 (0)