Skip to content

Commit 567b478

Browse files
committed
SIL: Use a scoped SILBuilder to insert dealloc_stacks for closure captures.
Fixes rdar://105701833.
1 parent 7018c55 commit 567b478

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/SILOptimizer/Utils/InstOptUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ void swift::insertDeallocOfCapturedArguments(PartialApplyInst *pai,
15191519
} else {
15201520
insertionPoint = terminator;
15211521
}
1522-
auto builder = SILBuilder(insertionPoint);
1522+
SILBuilderWithScope builder(insertionPoint);
15231523
builder.createDeallocStack(CleanupLocation(insertionPoint->getLoc()),
15241524
argValue);
15251525
}

test/SILOptimizer/closure-lifetime-fixup.sil

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all -closure-lifetime-fixup %s | %FileCheck %s
1+
// RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -closure-lifetime-fixup %s | %FileCheck %s
22

33
sil_stage raw
44

@@ -270,16 +270,16 @@ bb3:
270270
// CHECK: [[STACK:%[^,]+]] = alloc_stack $Self
271271
// CHECK: try_apply undef() {{.*}}, normal [[SUCCESS_1:bb[0-9]+]], error [[FAILURE_1:bb[0-9]+]]
272272
// CHECK: [[SUCCESS_1]]
273-
// CHECK: copy_addr [[INSTANCE]] to [init] [[STACK]] : $*Self
273+
// CHECK: copy_addr [[INSTANCE]] to [init] [[STACK]] : $*Self, {{.*}} scope [[STACK_SCOPE:[0-9]+]]
274274
// CHECK: [[CLOSURE:%[^,]+]] = partial_apply [callee_guaranteed] [on_stack] undef<Self>([[STACK]])
275275
// CHECK: [[DEPENDENCY:%[^,]+]] = mark_dependence [[CLOSURE]] {{.*}} on [[STACK]]
276276
// CHECK: try_apply undef([[DEPENDENCY]]) {{.*}}, normal [[SUCCESS_2:bb[0-9]+]], error [[FAILURE_2:bb[0-9]+]]
277277
// CHECK: [[SUCCESS_2]]
278278
// CHECK: destroy_value [[DEPENDENCY]]
279279
// CHECK: destroy_addr [[STACK]]
280-
// CHECK: dealloc_stack [[STACK]] : $*Self
280+
// CHECK: dealloc_stack [[STACK]] : $*Self, {{.*}} scope [[STACK_SCOPE]]
281281
// CHECK: [[FAILURE_1]]
282-
// CHECK: dealloc_stack [[STACK]]
282+
// CHECK: dealloc_stack [[STACK]] : $*Self, {{.*}} scope [[STACK_SCOPE]]
283283
// CHECK: throw
284284
// CHECK: [[FAILURE_2]]
285285
// CHECK-NOT: dealloc_stack

0 commit comments

Comments
 (0)