Skip to content

Commit 435636a

Browse files
committed
Emit line table entries for colusure 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
1 parent ce68d74 commit 435636a

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
@@ -3021,9 +3021,8 @@ RValueEmitter::emitClosureReference(AbstractClosureExpr *e,
30213021

30223022
// Generate the closure value (if any) for the closure expr's function
30233023
// reference.
3024-
SILLocation L = e;
3025-
L.markAutoGenerated();
3026-
return SGF.emitClosureValue(L, SILDeclRef(e), contextInfo, subs);
3024+
SILLocation loc = e;
3025+
return SGF.emitClosureValue(loc, SILDeclRef(e), contextInfo, subs);
30273026
}
30283027

30293028
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)