Skip to content

Commit 5e16173

Browse files
committed
Reuse the previous instruction's scope for line 0 locations
for easier-to-read debug info. This has no practical effect otherwise.
1 parent 9bde90c commit 5e16173

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,9 +1693,14 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) {
16931693
// Set the builder's debug location.
16941694
if (DS && !KeepCurrentLocation)
16951695
IGM.DebugInfo->setCurrentLoc(Builder, DS, ILoc);
1696-
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();
16971701
// Use an artificial (line 0) location.
16981702
IGM.DebugInfo->setCurrentLoc(Builder, DS);
1703+
}
16991704

17001705
if (isa<TermInst>(&I))
17011706
emitDebugVariableRangeExtension(BB);

0 commit comments

Comments
 (0)