Files
swift-mirror/test/SILOptimizer/existential_specializer2.sil
T
Erik Eckstein 3d84ab5845 ExistentialSpecializer: complete lifetimes in the generated thunk if needed
If the thunk calls to a no-return function, it is ended with an `unreachable`. This may introduce incomplete lifetimes.

Fixes a compiler crash
rdar://169555460
2026-02-06 15:44:52 +01:00

46 lines
1.3 KiB
Plaintext

// RUN: %target-sil-opt %s -existential-specializer -mandatory-performance-optimizations -sil-combine | %FileCheck %s
sil_stage canonical
import Builtin
import Swift
import SwiftShims
class C {}
public protocol P {}
public struct S : P {
var o: AnyObject
}
// Just check that we generate valid SIL
// CHECK-LABEL: sil [signature_optimized_thunk] [heuristic_always_inline] [ossa] @doesnt_return :
// CHECK: } // end sil function 'doesnt_return'
sil [ossa] @doesnt_return : $@convention(thin) (@in P, @inout P, @owned C) -> Never {
bb0(%0 : $*P, %1 : $*P, %2 : @owned $C):
copy_addr %0 to [init] %1
destroy_addr %0
destroy_value [dead_end] %2
unreachable
}
// Just check that we generate valid SIL
// CHECK-LABEL: sil [ossa] @specialize_no_return_function :
// CHECK-LABEL: } // end sil function 'specialize_no_return_function'
sil [ossa] @specialize_no_return_function : $@convention(thin) (@owned S, @inout P, @owned C) -> () {
bb0(%0 : @owned $S, %1 : $*P, %2 : @owned $C):
%4 = alloc_stack $P
%5 = init_existential_addr %4, $S
store %0 to [init] %5
%7 = function_ref @doesnt_return : $@convention(thin) (@in P, @inout P, @owned C) -> Never
%8 = apply %7(%4, %1, %2) : $@convention(thin) (@in P, @inout P, @owned C) -> Never
dealloc_stack %4 : $*P
%10 = tuple ()
return %10 : $()
}
sil_witness_table S: P module test {}