Skip to content

Commit 2aa80e2

Browse files
Merge pull request #3409 from adrian-prantl/26221951
Don't emit line table entries for SIL functions marked as thunks.
2 parents c7b21e3 + 3ffaa76 commit 2aa80e2

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,18 @@ void IRGenDebugInfo::setCurrentLoc(IRBuilder &Builder, const SILDebugScope *DS,
327327
// })
328328
//
329329
// The actual closure has a closure expression as scope.
330-
if (Loc && isAbstractClosure(*Loc) && DS && !isAbstractClosure(DS->Loc)
331-
&& !Loc->is<ImplicitReturnLocation>()) {
330+
if (Loc && isAbstractClosure(*Loc) && DS && !isAbstractClosure(DS->Loc) &&
331+
!Loc->is<ImplicitReturnLocation>())
332332
L.Line = L.Column = 0;
333-
}
334333

335-
if (L.Line == 0 && DS == LastScope) {
336-
// Reuse the last source location if we are still in the same
337-
// scope to get a more contiguous line table.
334+
if (auto *Fn = DS->getInlinedFunction())
335+
if (Fn->isThunk())
336+
L.Line = L.Column = 0;
337+
338+
// Reuse the last source location if we are still in the same
339+
// scope to get a more contiguous line table.
340+
if (L.Line == 0 && DS == LastScope)
338341
L = LastDebugLoc;
339-
}
340342

341343
// FIXME: Enable this assertion.
342344
//assert(lineNumberIsSane(Builder, L.Line) &&
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-swift-frontend %s -emit-ir -g -o - | FileCheck %s
2+
3+
public class C {
4+
5+
// Test that curry thunks don't have line table entries.
6+
// CHECK: define {{.*}}@_TFC4main1C11someHandlerFT_T_(%C4main1C*)
7+
// CHECK-SAME: !dbg ![[CURRY_THUNK:[0-9]+]]
8+
// CHECK-NOT: ret {{.*}},
9+
// CHECK: {{.*}}, !dbg ![[DBG:[0-9]+]]
10+
// CHECK: ret {{.*}}, !dbg ![[DBG]]
11+
// CHECK: ![[DBG]] = !DILocation(line: 0, scope: ![[CURRY_THUNK]])
12+
func someHandler() { }
13+
14+
func doSomethingWithHandler(_ theHandler: ((Void) -> Void)!) -> Void {
15+
theHandler()
16+
}
17+
18+
public func entry() {
19+
doSomethingWithHandler(someHandler)
20+
}
21+
}

0 commit comments

Comments
 (0)