mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
This commit is contained in:
@@ -3021,9 +3021,8 @@ RValueEmitter::emitClosureReference(AbstractClosureExpr *e,
|
||||
|
||||
// Generate the closure value (if any) for the closure expr's function
|
||||
// reference.
|
||||
SILLocation L = e;
|
||||
L.markAutoGenerated();
|
||||
return SGF.emitClosureValue(L, SILDeclRef(e), contextInfo, subs);
|
||||
SILLocation loc = e;
|
||||
return SGF.emitClosureValue(loc, SILDeclRef(e), contextInfo, subs);
|
||||
}
|
||||
|
||||
RValue RValueEmitter::
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
public func g<T>(_ t: T) {}
|
||||
public func f(_ i: Int32) {
|
||||
// CHECK: function_ref @$s4main1fyys5Int32VFyycfU_
|
||||
// CHECK-SAME: loc * "{{.*}}":13:3,
|
||||
// CHECK-SAME: loc "{{.*}}":13:3,
|
||||
// CHECK: %[[CLOSURE:.*]] = partial_apply
|
||||
// CHECK-SAME: loc * "{{.*}}":13:3,{{.*}}auto_gen
|
||||
// CHECK-SAME: loc "{{.*}}":13:3,
|
||||
// CHECK: store %[[CLOSURE]]
|
||||
// CHECK-SAME: loc "{{.*}}":13:3,
|
||||
// CHECK-SAME: loc "{{.*}}":13:3,
|
||||
var closure = // line 12
|
||||
{ // FIXME: Shoudll the store be associated with line 12?
|
||||
{
|
||||
g(i)
|
||||
}
|
||||
return closure()
|
||||
|
||||
@@ -213,7 +213,7 @@ func captures_tuple<T, U>(x: (T, U)) -> () -> (T, U) {
|
||||
// CHECK-LABEL: sil hidden [ossa] @$s13sil_locations14captures_tuple{{[_0-9a-zA-Z]*}}F
|
||||
// CHECK: tuple_element_addr {{.*}}, loc "{{.*}}":[[@LINE-3]]:27
|
||||
// CHECK: copy_addr {{.*}}, loc "{{.*}}":[[@LINE-4]]:27
|
||||
// CHECK: function_ref {{.*}}, loc * "{{.*}}":[[@LINE-4]]:10
|
||||
// CHECK: function_ref {{.*}}, loc "{{.*}}":[[@LINE-4]]:10
|
||||
|
||||
// CHECK-LABEL: sil private [ossa] @$s13sil_locations14captures_tuple{{.*}}fU_
|
||||
// CHECK: copy_addr {{.*}}, loc "{{.*}}":[[@LINE-7]]:11
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// Make sure project_box gets assigned the correct lexical scope when we create it.
|
||||
// RUN: %target-swift-frontend -primary-file %s -Onone -emit-sil -Xllvm -sil-print-after=capture-promotion -Xllvm \
|
||||
// RUN: -sil-print-debuginfo -o /dev/null -module-name null 2>&1 | %FileCheck %s
|
||||
|
||||
// CHECK: sil hidden [ossa] @$s4null19captureStackPromoteSiycyF : $@convention(thin) () -> @owned @callee_guaranteed () -> Int {
|
||||
// CHECK: bb0:
|
||||
// CHECK: [[BOX:%[^,]+]] = alloc_box ${ var Int }, var, name "x", loc {{.*}}:32:7, scope 3
|
||||
// CHECK: [[BOX_LIFETIME:%[^,]+]] = begin_borrow [var_decl] [[BOX]]
|
||||
// CHECK: [[BOX_ADDR:%[^,]+]] = project_box [[BOX_LIFETIME]] : ${ var Int }, 0, loc {{.*}}:32:7, scope 3
|
||||
// CHECK: [[ONE:%[^,]+]] = integer_literal $Builtin.IntLiteral, 1, loc {{.*}}:32:11, scope 4
|
||||
// CHECK: [[THIN_INT_TYPE:%[^,]+]] = metatype $@thin Int.Type, loc {{.*}}:32:11, scope 4
|
||||
// CHECK: [[INTEGER_LITERAL:%[^,]+]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int, loc {{.*}}:32:11, scope 4
|
||||
// CHECK: [[ONE_INT:%[^,]+]] = apply [[INTEGER_LITERAL]]([[ONE]], [[THIN_INT_TYPE]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int, loc {{.*}}:32:11, scope 4
|
||||
// CHECK: store [[ONE_INT]] to [trivial] [[BOX_ADDR]] : $*Int, loc {{.*}}:32:11, scope 4
|
||||
// CHECK: [[BOX_COPY:%[^,]+]] = copy_value [[BOX_LIFETIME]] : ${ var Int }, loc {{.*}}:33:11, scope 4
|
||||
// CHECK: [[BOX_COPY_ADDR:%[^,]+]] = project_box [[BOX_COPY]] : ${ var Int }, 0, loc {{.*}}:33:11, scope 4
|
||||
// CHECK: mark_function_escape [[BOX_ADDR]] : $*Int, loc {{.*}}:33:11, scope 4
|
||||
// CHECK: [[SPECIALIZED_F:%[^,]+]] = function_ref @$s4null19captureStackPromoteSiycyFSiycfU_Tf2i_n : $@convention(thin) (Int) -> Int, loc {{.*}}:33:11, scope 4
|
||||
// CHECK: [[REGISTER_11:%[^,]+]] = load [trivial] [[BOX_COPY_ADDR]] : $*Int, loc {{.*}}:33:11, scope 4
|
||||
// CHECK: destroy_value [[BOX_COPY]] : ${ var Int }, loc {{.*}}:33:11, scope 4
|
||||
// CHECK: [[CLOSURE:%[^,]+]] = partial_apply [callee_guaranteed] [[SPECIALIZED_F]]([[REGISTER_11]]) : $@convention(thin) (Int) -> Int, loc {{.*}}:33:11, scope 4
|
||||
// CHECK: [[MOVE:%.*]] = move_value [lexical] [var_decl] [[CLOSURE]]
|
||||
// CHECK: debug_value [[MOVE]] : $@callee_guaranteed () -> Int, let, name "f", loc {{.*}}:33:7, scope 6
|
||||
// CHECK: [[CLOSURE_COPY:%[^,]+]] = copy_value [[MOVE]] : $@callee_guaranteed () -> Int, loc {{.*}}:34:10, scope 6
|
||||
// There used to be an end_borrow here. We leave an emptyline here to preserve line numbers.
|
||||
// CHECK: destroy_value [[MOVE]] : $@callee_guaranteed () -> Int, loc {{.*}}:35:1, scope 6
|
||||
// CHECK: destroy_value [[BOX]] : ${ var Int }, loc {{.*}}:35:1, scope 6
|
||||
// CHECK: return [[CLOSURE_COPY]] : $@callee_guaranteed () -> Int, loc {{.*}}:34:3, scope 6
|
||||
// CHECK: }
|
||||
|
||||
func captureStackPromote() -> () -> Int {
|
||||
var x = 1
|
||||
let f = { x }
|
||||
return f
|
||||
}
|
||||
Reference in New Issue
Block a user