From fadfedacfe5ad1d20f390d304e6e25c3952fdaba Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 21 Feb 2023 13:59:00 -0800 Subject: [PATCH] SIL: Use a scoped SILBuilder to insert dealloc_stacks for closure captures. Fixes rdar://105701833. (cherry picked from commit 567b4786a57741dfcb929137a25f53244bd18e8b) --- lib/SILOptimizer/Utils/InstOptUtils.cpp | 2 +- test/SILOptimizer/closure-lifetime-fixup.sil | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/SILOptimizer/Utils/InstOptUtils.cpp b/lib/SILOptimizer/Utils/InstOptUtils.cpp index e94779694fce6..794a59b82b206 100644 --- a/lib/SILOptimizer/Utils/InstOptUtils.cpp +++ b/lib/SILOptimizer/Utils/InstOptUtils.cpp @@ -1507,7 +1507,7 @@ void swift::insertDeallocOfCapturedArguments(PartialApplyInst *pai, } else { insertionPoint = terminator; } - auto builder = SILBuilder(insertionPoint); + SILBuilderWithScope builder(insertionPoint); builder.createDeallocStack(CleanupLocation(insertionPoint->getLoc()), arg.get()); } diff --git a/test/SILOptimizer/closure-lifetime-fixup.sil b/test/SILOptimizer/closure-lifetime-fixup.sil index 3c8774d83196a..017b364db0a47 100644 --- a/test/SILOptimizer/closure-lifetime-fixup.sil +++ b/test/SILOptimizer/closure-lifetime-fixup.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -enable-sil-verify-all -closure-lifetime-fixup %s | %FileCheck %s +// RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -closure-lifetime-fixup %s | %FileCheck %s sil_stage raw @@ -261,16 +261,16 @@ bb3: // CHECK: [[STACK:%[^,]+]] = alloc_stack $Self // CHECK: try_apply undef() {{.*}}, normal [[SUCCESS_1:bb[0-9]+]], error [[FAILURE_1:bb[0-9]+]] // CHECK: [[SUCCESS_1]] -// CHECK: copy_addr [[INSTANCE]] to [init] [[STACK]] : $*Self +// CHECK: copy_addr [[INSTANCE]] to [init] [[STACK]] : $*Self, {{.*}} scope [[STACK_SCOPE:[0-9]+]] // CHECK: [[CLOSURE:%[^,]+]] = partial_apply [callee_guaranteed] [on_stack] undef([[STACK]]) // CHECK: [[DEPENDENCY:%[^,]+]] = mark_dependence [[CLOSURE]] {{.*}} on [[STACK]] // CHECK: try_apply undef([[DEPENDENCY]]) {{.*}}, normal [[SUCCESS_2:bb[0-9]+]], error [[FAILURE_2:bb[0-9]+]] // CHECK: [[SUCCESS_2]] // CHECK: dealloc_stack [[CLOSURE]] // CHECK: destroy_addr [[STACK]] -// CHECK: dealloc_stack [[STACK]] : $*Self +// CHECK: dealloc_stack [[STACK]] : $*Self, {{.*}} scope [[STACK_SCOPE]] // CHECK: [[FAILURE_1]] -// CHECK: dealloc_stack [[STACK]] +// CHECK: dealloc_stack [[STACK]] : $*Self, {{.*}} scope [[STACK_SCOPE]] // CHECK: throw // CHECK: [[FAILURE_2]] // CHECK-NOT: dealloc_stack