Skip to content

Commit 014876d

Browse files
committed
[SILOpt] Enabled SSADestroyHoisting.
The new destroy_addr hoisting respects lexical lifetimes. It will replace all other destory hoisting.
1 parent 137a160 commit 014876d

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ void addFunctionPasses(SILPassPipelinePlan &P,
346346
// Promote box allocations to stack allocations.
347347
P.addAllocBoxToStack();
348348

349+
P.addSSADestroyHoisting();
350+
349351
// Propagate copies through stack locations. Should run after
350352
// box-to-stack promotion since it is limited to propagating through
351353
// stack locations. Should run before aggregate lowering since that

test/SILOptimizer/bridged_casts_folding.sil

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ bb3(%8 : @owned $NSObjectSubclass):
4949

5050
// CHECK-LABEL: sil @anyhashable_cast_take_on_success
5151
// CHECK: [[BRIDGED:%.*]] = apply {{.*}}(%0)
52-
// CHECK-NEXT: checked_cast_br [[BRIDGED]] : $NSObject to NSObjectSubclass, [[YES:bb[0-9]+]], [[NO:bb[0-9]+]]
53-
// CHECK: [[YES]]{{.*}}:
5452
// CHECK-NEXT: destroy_addr %0
53+
// CHECK-NEXT: checked_cast_br [[BRIDGED]] : $NSObject to NSObjectSubclass, {{bb[0-9]+}}, {{bb[0-9]+}}
5554
sil [ossa] @anyhashable_cast_take_on_success : $@convention(thin) (@in AnyHashable, @owned NSObjectSubclass) -> @owned NSObjectSubclass {
5655
entry(%0 : $*AnyHashable, %1 : @owned $NSObjectSubclass):
5756
%2 = alloc_stack $NSObjectSubclass

test/SILOptimizer/bridged_casts_folding_ownership.sil

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ bb3(%8 : @owned $NSObjectSubclass):
5151

5252
// CHECK-LABEL: sil @anyhashable_cast_take_on_success
5353
// CHECK: [[BRIDGED:%.*]] = apply {{.*}}(%0)
54-
// CHECK-NEXT: checked_cast_br [[BRIDGED]] : $NSObject to NSObjectSubclass, [[YES:bb[0-9]+]], [[NO:bb[0-9]+]]
55-
// CHECK: [[YES]]{{.*}}:
5654
// CHECK-NEXT: destroy_addr %0
55+
// CHECK-NEXT: checked_cast_br [[BRIDGED]] : $NSObject to NSObjectSubclass, [[YES:bb[0-9]+]], [[NO:bb[0-9]+]]
5756
sil [ossa] @anyhashable_cast_take_on_success : $@convention(thin) (@in AnyHashable, @owned NSObjectSubclass) -> @owned NSObjectSubclass {
5857
entry(%0 : $*AnyHashable, %1 : @owned $NSObjectSubclass):
5958
%2 = alloc_stack $NSObjectSubclass

test/SILOptimizer/capture_promotion_generic_context_ownership.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ entry(%0 : $*T, %b : @owned $<τ_0_0> { var τ_0_0 } <Int>):
5353

5454
// CHECK-LABEL: sil @call_generic_promotable_box_from_different_generic
5555
// CHECK: bb0([[ARG0:%.*]] : $*T, [[ARG1:%.*]] : $*U, [[ARG2:%.*]] : $Builtin.Int32):
56-
// CHECK-NEXT: destroy_addr [[ARG0]] : $*T
5756
// CHECK-NEXT: destroy_addr [[ARG1]] : $*U
57+
// CHECK-NEXT: destroy_addr [[ARG0]] : $*T
5858
// CHECK: [[F:%.*]] = function_ref @$s22generic_promotable_boxTf2ni_n : $@convention(thin) <τ_0_0> (@in τ_0_0, Builtin.Int32) -> Builtin.Int32
5959
// CHECK-NEXT: [[CLOSURE:%.*]] = partial_apply [callee_guaranteed] [[F]]<U>([[ARG2]])
6060
// CHECK-NEXT: return [[CLOSURE]]

0 commit comments

Comments
 (0)