File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -2192,6 +2192,12 @@ bool MemoryToRegisters::promoteAllocation(AllocStackInst *alloc,
21922192 return true ;
21932193 }
21942194
2195+ // The value stored into an alloc_stack whose type address-only can never be
2196+ // represented in a register. Bail out.
2197+ if (alloc->getType ().isAddressOnly (f)) {
2198+ return false ;
2199+ }
2200+
21952201 // For AllocStacks that are only used within a single basic blocks, use
21962202 // the linear sweep to remove the AllocStack.
21972203 if (inSingleBlock) {
Original file line number Diff line number Diff line change 22
33import Builtin
44import Swift
5+ import _Concurrency
56
67//////////////////
78// Declarations //
@@ -547,3 +548,33 @@ bb0:
547548 dealloc_stack %11 : $*(Builtin.BridgeObject, ())
548549 return undef : $()
549550}
551+
552+ typealias ResilientTy = CheckedContinuation<(), Error>
553+
554+ // CHECK-LABEL: sil @dont_promote_addronly_aggregate : {{.*}} {
555+ // CHECK: alloc_stack
556+ // CHECK-LABEL: } // end sil function 'dont_promote_addronly_aggregate'
557+ sil @dont_promote_addronly_aggregate : $@convention(thin) () -> () {
558+ bb0:
559+ %11 = alloc_stack $Pair<ResilientTy, ()>
560+ %12 = struct_element_addr %11 : $*Pair<ResilientTy, ()>, #Pair.u
561+ %13 = load %12 : $*()
562+ %empty = tuple ()
563+ %14 = tuple (%empty : $(), %13 : $())
564+ dealloc_stack %11 : $*Pair<ResilientTy, ()>
565+ return undef : $()
566+ }
567+
568+ // CHECK-LABEL: sil @dont_promote_addronly_aggregate_2 : {{.*}} {
569+ // CHECK: alloc_stack
570+ // CHECK-LABEL: } // end sil function 'dont_promote_addronly_aggregate_2'
571+ sil @dont_promote_addronly_aggregate_2 : $@convention(thin) <T> () -> () {
572+ bb0:
573+ %11 = alloc_stack $Pair<T, ()>
574+ %12 = struct_element_addr %11 : $*Pair<T, ()>, #Pair.u
575+ %13 = load %12 : $*()
576+ %empty = tuple ()
577+ %14 = tuple (%empty : $(), %13 : $())
578+ dealloc_stack %11 : $*Pair<T, ()>
579+ return undef : $()
580+ }
You can’t perform that action at this time.
0 commit comments