@@ -22,6 +22,15 @@ import pre_specialized_module_layouts
2222@inline ( never)
2323public func consume< T> ( _ x: T ) { }
2424
25+ public struct ReferenceWrapperStruct {
26+ let x : AnyObject
27+ }
28+
29+ @_alignment ( 16 )
30+ public struct OveralignedReferenceWrapperStruct {
31+ let x : AnyObject
32+ }
33+
2534// Make sure we generate the public pre-specialized entry points.
2635
2736// OPT-DAG: sil @$s22pre_specialize_layouts10testPublic1tyx_tlFSf_Ts5 : $@convention(thin) (Float) -> () {
@@ -63,7 +72,8 @@ internal func testEmitIntoClient<T>(t: T) {
6372 print ( t)
6473}
6574
66- // OPT: sil @$s22pre_specialize_layouts28usePrespecializedEntryPointsyyF : $@convention(thin) () -> () {
75+ // OPT: sil @$s22pre_specialize_layouts28usePrespecializedEntryPoints13wrapperStruct11overalignedyAA016ReferenceWrapperI0V_AA011OveralignedklI0VtF : $@convention(thin) (@guaranteed ReferenceWrapperStruct, @guaranteed OveralignedReferenceWrapperStruct) -> () {
76+ // OPT: bb0([[P1:%.*]] : $ReferenceWrapperStruct, [[P2:%.*]] : $OveralignedReferenceWrapperStruct):
6777// OPT: [[F1:%.*]] = function_ref @$s30pre_specialized_module_layouts20publicPrespecializedyyxlFSi_Ts5 : $@convention(thin) (Int) -> ()
6878// OPT: apply [[F1]]
6979// OPT: [[F2:%.*]] = function_ref @$s30pre_specialized_module_layouts20publicPrespecializedyyxlFSd_Ts5 : $@convention(thin) (Double) -> ()
@@ -73,13 +83,17 @@ internal func testEmitIntoClient<T>(t: T) {
7383// OPT: [[F7:%.*]] = function_ref @$s30pre_specialized_module_layouts20publicPrespecializedyyxlFyXl_Ts5 : $@convention(thin) (@guaranteed AnyObject) -> ()
7484// OPT: [[A1:%.*]] = unchecked_ref_cast {{%.*}} : $SomeClass to $AnyObject
7585// OPT: apply [[F7]]([[A1]]) : $@convention(thin) (@guaranteed AnyObject) -> ()
86+ // OPT: [[A2:%.*]] = unchecked_bitwise_cast [[P1]] : $ReferenceWrapperStruct to $AnyObject
87+ // OPT: apply [[F7]]([[A2]]) : $@convention(thin) (@guaranteed AnyObject) -> ()
88+ // OPT: [[A3:%.*]] = alloc_stack $OveralignedReferenceWrapperStruct
89+ // OPT: apply {{%.*}}<OveralignedReferenceWrapperStruct>([[A3]])
7690// OPT: [[F3:%.*]] = function_ref @$s30pre_specialized_module_layouts36internalEmitIntoClientPrespecializedyyxlFSi_Ts5 : $@convention(thin) (Int) -> ()
7791// OPT: apply [[F3]]
7892// OPT: [[F4:%.*]] = function_ref @$s30pre_specialized_module_layouts36internalEmitIntoClientPrespecializedyyxlFSd_Ts5 : $@convention(thin) (Double) -> ()
7993// OPT: apply [[F4]]
8094// OPT: [[F5:%.*]] = function_ref @$s30pre_specialized_module_layouts16useInternalThingyyxlFSi_Tg5
8195// OPT: apply [[F5]]({{.*}}) : $@convention(thin) (Int) -> ()
82- // OPT: } // end sil function '$s22pre_specialize_layouts28usePrespecializedEntryPointsyyF '
96+ // OPT: } // end sil function '$s22pre_specialize_layouts28usePrespecializedEntryPoints13wrapperStruct11overalignedyAA016ReferenceWrapperI0V_AA011OveralignedklI0VtF '
8397
8498// OPT: sil {{.*}} @$s30pre_specialized_module_layouts16useInternalThingyyxlFSi_Tg5 : $@convention(thin) (Int) -> () {
8599// OPT: [[F1:%.*]] = function_ref @$s30pre_specialized_module_layouts14InternalThing2V7computexyFSi_Ts5 : $@convention(method) (InternalThing2<Int>) -> Int
@@ -124,11 +138,14 @@ internal func testEmitIntoClient<T>(t: T) {
124138// OPT: [[R10:%.*]] = unchecked_addr_cast [[R9]] : $*AnyObject to $*SomeClass
125139// OPT: } // end sil function '$s30pre_specialized_module_layouts16useInternalThingyyxlFAA9SomeClassC_Tg5'
126140
127- public func usePrespecializedEntryPoints( ) {
141+ public func usePrespecializedEntryPoints( wrapperStruct : ReferenceWrapperStruct , overaligned : OveralignedReferenceWrapperStruct ) {
128142 publicPrespecialized ( 1 )
129143 publicPrespecialized ( 1.0 )
130144 publicPrespecialized ( SomeData ( ) )
131145 publicPrespecialized ( SomeClass ( ) )
146+ publicPrespecialized ( wrapperStruct)
147+ // should not apply _Class specialization for overaligned struct
148+ publicPrespecialized ( overaligned)
132149 useInternalEmitIntoClientPrespecialized ( 2 )
133150 useInternalEmitIntoClientPrespecialized ( 2.0 )
134151 useInternalThing ( 2 )
0 commit comments