Skip to content

Commit 5bb50c0

Browse files
committed
Emit line table entries for closure setup instructions.
Currently the Swift compiler makes these instructions with SILLocations marked as autgenerated. While this allows for somewhat smoother stepping in some cases, it can also make some debugging tasks harder due to missing source location information, for example, when attributing memory allocations. This patch makes these locations available again, based on that a debug info consumer could consider filtering them out by recognizing that a source location is on the opening `{` of a closure, but inside the scope of the function the closure is defined in. rdar://127095833 (cherry picked from commit 82a26a5)
1 parent 8781d12 commit 5bb50c0

File tree

4 files changed

+7
-43
lines changed

4 files changed

+7
-43
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,9 +3049,8 @@ RValueEmitter::emitClosureReference(AbstractClosureExpr *e,
30493049

30503050
// Generate the closure value (if any) for the closure expr's function
30513051
// reference.
3052-
SILLocation L = e;
3053-
L.markAutoGenerated();
3054-
return SGF.emitClosureValue(L, SILDeclRef(e), contextInfo, subs);
3052+
SILLocation loc = e;
3053+
return SGF.emitClosureValue(loc, SILDeclRef(e), contextInfo, subs);
30553054
}
30563055

30573056
RValue RValueEmitter::

test/DebugInfo/linetable-assign.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
public func g<T>(_ t: T) {}
55
public func f(_ i: Int32) {
66
// CHECK: function_ref @$s4main1fyys5Int32VFyycfU_
7-
// CHECK-SAME: loc * "{{.*}}":13:3,
7+
// CHECK-SAME: loc "{{.*}}":13:3,
88
// CHECK: %[[CLOSURE:.*]] = partial_apply
9-
// CHECK-SAME: loc * "{{.*}}":13:3,{{.*}}auto_gen
9+
// CHECK-SAME: loc "{{.*}}":13:3,
1010
// CHECK: store %[[CLOSURE]]
11-
// CHECK-SAME: loc "{{.*}}":13:3,
11+
// CHECK-SAME: loc "{{.*}}":13:3,
1212
var closure = // line 12
13-
{ // FIXME: Shoudll the store be associated with line 12?
13+
{
1414
g(i)
1515
}
1616
return closure()

test/SILGen/sil_locations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func captures_tuple<T, U>(x: (T, U)) -> () -> (T, U) {
213213
// CHECK-LABEL: sil hidden [ossa] @$s13sil_locations14captures_tuple{{[_0-9a-zA-Z]*}}F
214214
// CHECK: tuple_element_addr {{.*}}, loc "{{.*}}":[[@LINE-3]]:27
215215
// CHECK: copy_addr {{.*}}, loc "{{.*}}":[[@LINE-4]]:27
216-
// CHECK: function_ref {{.*}}, loc * "{{.*}}":[[@LINE-4]]:10
216+
// CHECK: function_ref {{.*}}, loc "{{.*}}":[[@LINE-4]]:10
217217

218218
// CHECK-LABEL: sil private [ossa] @$s13sil_locations14captures_tuple{{.*}}fU_
219219
// CHECK: copy_addr {{.*}}, loc "{{.*}}":[[@LINE-7]]:11

test/SILOptimizer/capturepromotion-wrong-lexicalscope.swift

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)