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 @@ -2203,6 +2203,12 @@ bool MemoryToRegisters::promoteAllocation(AllocStackInst *alloc,
22032203 return true ;
22042204 }
22052205
2206+ // The value stored into an alloc_stack whose type address-only can never be
2207+ // represented in a register. Bail out.
2208+ if (alloc->getType ().isAddressOnly (f)) {
2209+ return false ;
2210+ }
2211+
22062212 // For AllocStacks that are only used within a single basic blocks, use
22072213 // the linear sweep to remove the AllocStack.
22082214 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