Skip to content

Commit aec1c8c

Browse files
authored
Merge pull request #40787 from gottesmm/release/5.6/rdar86535218
[allocbox-to-stack] Loosen an assert.
2 parents bdafd9b + 6dd5545 commit aec1c8c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lib/SILOptimizer/Transforms/AllocBoxToStack.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ specializeApplySite(SILOptFunctionBuilder &FuncBuilder, ApplySite Apply,
932932
SILValue Box = O.get();
933933
assert((isa<SingleValueInstruction>(Box) && isa<AllocBoxInst>(Box) ||
934934
isa<CopyValueInst>(Box) ||
935+
isa<MarkUninitializedInst>(Box) ||
935936
isa<SILFunctionArgument>(Box)) &&
936937
"Expected either an alloc box or a copy of an alloc box or a "
937938
"function argument");

test/SILOptimizer/allocbox_to_stack_ownership.sil

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,39 @@ bb0(%0 : $*T):
556556
}
557557
// CHECK: } // end sil function 'callWithAutoclosure_2'
558558

559+
// CHECK-LABEL: sil [ossa] @callWithAutoclosure_3 : $@convention(thin) <T where T : P> (@in T) -> () {
560+
sil [ossa] @callWithAutoclosure_3 : $@convention(thin) <T where T : P> (@in T) -> () {
561+
// CHECK: bb0
562+
bb0(%0 : $*T):
563+
// CHECK: debug_value {{.*}} expr op_deref
564+
debug_value %0 : $*T, expr op_deref
565+
// CHECK: function_ref @mightApply
566+
%2 = function_ref @mightApply : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned @callee_owned () -> @out τ_0_0) -> ()
567+
%3 = function_ref @closure_to_specialize : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned <τ_0_0> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0
568+
// CHECK-NOT: alloc_box
569+
// CHECK: [[STACK_UNMARKED:%[0-9a-zA-Z_]+]] = alloc_stack $T
570+
// CHECK: [[STACK:%.*]] = mark_uninitialized [var] [[STACK_UNMARKED]]
571+
%4 = alloc_box $<τ_0_0> { var τ_0_0 } <T>
572+
%4c = mark_uninitialized [var] %4 : $<τ_0_0> { var τ_0_0 } <T>
573+
%4a = project_box %4c : $<τ_0_0> { var τ_0_0 } <T>, 0
574+
%4copy = copy_value %4c : $<τ_0_0> { var τ_0_0 } <T>
575+
// CHECK: copy_addr %0 to [initialization] [[STACK]] : $*T
576+
copy_addr %0 to [initialization] %4a : $*T
577+
// CHECK: [[CLOSURE:%[0-9a-zA-Z]+]] = function_ref @$s21closure_to_specializeTf0ns_n
578+
// CHECK: partial_apply [[CLOSURE]]<T>([[STACK]])
579+
%6 = partial_apply %3<T>(%4copy) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned <τ_0_0> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0
580+
%7 = apply %2<T>(%6) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned @callee_owned () -> @out τ_0_0) -> ()
581+
// CHECK: destroy_addr [[STACK]] : $*T
582+
// CHECK: dealloc_stack [[STACK_UNMARKED]] : $*T
583+
destroy_addr %0 : $*T
584+
destroy_value %4c : $<τ_0_0> { var τ_0_0 } <T>
585+
%9 = tuple ()
586+
// CHECK: return
587+
return %9 : $()
588+
}
589+
// CHECK: } // end sil function 'callWithAutoclosure_3'
590+
591+
559592
// CHECK-LABEL: sil shared [ossa] @$s21closure_to_specializeTf0ns_n : $@convention(thin) <T where T : P> (@inout_aliasable T) -> @out T
560593
sil shared [ossa] @closure_to_specialize : $@convention(thin) <T where T : P> (@owned <τ_0_0> { var τ_0_0 } <T>) -> @out T {
561594
// CHECK: bb0

0 commit comments

Comments
 (0)