| // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -emit-ir | %FileCheck %s |
| |
| // REQUIRES: CPU=x86_64 |
| |
| import Swift |
| |
| // CHECK-LABEL: @"$S18field_type_vectors3FooVMn" = hidden constant |
| // CHECK: %swift.type** (%swift.type*)* [[FOO_TYPES_ACCESSOR:@[A-Za-z0-9_]*]] |
| struct Foo { |
| var x: Int |
| } |
| |
| // CHECK-LABEL: @"$S18field_type_vectors3BarVMn" = hidden constant |
| // CHECK: %swift.type** (%swift.type*)* [[BAR_TYPES_ACCESSOR:@[A-Za-z0-9_]*]] |
| // CHECK-LABEL: @"$S18field_type_vectors3BarVMP" = internal global |
| // -- There should be 1 word between the field type vector slot, with type %swift.type**, |
| // and the address point |
| // CHECK: %swift.type**, i8**, i64, <{ {{.*}} }>*, %swift.type*, i64 |
| struct Bar<T> { |
| var y: Int |
| } |
| |
| // CHECK-LABEL: @"$S18field_type_vectors3BasVMn" = hidden constant |
| // CHECK: %swift.type** (%swift.type*)* [[BAS_TYPES_ACCESSOR:@[A-Za-z0-9_]*]] |
| // CHECK-LABEL: @"$S18field_type_vectors3BasVMP" = internal global |
| // -- There should be 1 word between the field type vector slot, with type %swift.type**, |
| // and the address point |
| // CHECK: %swift.type**, i8**, i64, <{ {{.*}} }>*, %swift.type*, %swift.type*, i64, i64 |
| struct Bas<T, U> { |
| var foo: Foo |
| var bar: Bar<T> |
| } |
| |
| // CHECK-LABEL: @"$S18field_type_vectors3ZimCMn" = hidden constant |
| // CHECK: %swift.type** (%swift.type*)* [[ZIM_TYPES_ACCESSOR:@[A-Za-z0-9_]*]] |
| // CHECK-LABEL: @"$S18field_type_vectors3ZimCMP" = internal global |
| // -- There should be 1 word between the field type vector slot, with type %swift.type**, |
| // and the address point |
| // CHECK: %swift.type**, i8*, i8**, i64, %swift.type*, %swift.opaque*, %swift.opaque*, i64, i32, i32, i32, i16, i16, i32, i32, <{ {{.*}} }>*, i8* |
| class Zim<T, U> { |
| var foo: Foo? |
| var bar: Bar<T>? |
| var bas: Bas<T, U>? |
| } |
| sil_vtable Zim {} |
| |
| sil @_TFC18field_type_vectors3ZimcU___fMGS0_Q_Q0__FT_GS0_Q_Q0__ : $@convention(method) <T, U> (@owned Zim<T, U>) -> @owned Zim<T, U> |
| |
| // CHECK-LABEL: @"$S18field_type_vectors4ZangCMn" = hidden constant |
| // CHECK: %swift.type** (%swift.type*)* [[ZANG_TYPES_ACCESSOR:@[A-Za-z0-9_]*]] |
| // CHECK-LABEL: @"$S18field_type_vectors4ZangCMP" = internal global |
| // -- There should be 1 word between the field type vector slot, with type %swift.type**, |
| // and the address point |
| // CHECK: %swift.type**, i8*, i8**, i64, %swift.type*, %swift.opaque*, %swift.opaque*, i64, i32, i32, i32, i16, i16, i32, i32, <{ {{.*}} }>*, i8* |
| class Zang<V>: Zim<V, V> { |
| var zung: Int = 0 |
| } |
| sil_vtable Zang {} |
| |
| sil @_TFC18field_type_vectors4ZangcU__fMGS0_Q__FT_GS0_Q__ : $@convention(method) <V> (@owned Zang<V>) -> @owned Zang<V> |
| |
| // -- For storage-qualified fields, we just report the formal type. |
| class StorageQualified { |
| unowned var a: StorageQualified |
| weak var b: StorageQualified? |
| |
| init(x: StorageQualified) { |
| a = x |
| b = x |
| } |
| } |
| sil_vtable StorageQualified {} |
| |
| // CHECK: [[FOO_TYPE_VECTOR_SLOT:@.*Foo.*]] = private global %swift.type** null |
| |
| // CHECK: define{{( protected)?}} private %swift.type** [[FOO_TYPES_ACCESSOR]](%swift.type* %Foo) |
| // CHECK: [[EXISTING:%.*]] = load %swift.type**, %swift.type*** [[FOO_TYPE_VECTOR_SLOT]] |
| // CHECK: [[IS_NULL:%.*]] = icmp eq %swift.type** [[EXISTING]], null |
| // CHECK: br i1 [[IS_NULL]], label %[[BUILD_FIELD_TYPES:.*]], label %[[DONE:.*]] |
| // CHECK: [[BUILD_FIELD_TYPES]]: |
| // CHECK: store {{.*}} @"$SSiN" |
| // CHECK: cmpxchg {{.*}} [[FOO_TYPE_VECTOR_SLOT]] |
| |
| // CHECK: define{{( protected)?}} private %swift.type** [[BAR_TYPES_ACCESSOR]](%swift.type* %"Bar<T>") |
| // CHECK: [[T0:%.*]] = bitcast %swift.type* %"Bar<T>" to %swift.type*** |
| // CHECK: [[SLOT:%.*]] = getelementptr inbounds %swift.type**, %swift.type*** [[T0]], i64 -2 |
| // CHECK: load %swift.type**, %swift.type*** [[SLOT]], align 8 |
| // CHECK: br |
| // CHECK-NOT: load %swift.type*, |
| // CHECK: store {{.*}} @"$SSiN" |
| |
| |
| // CHECK: define{{( protected)?}} private %swift.type** [[BAS_TYPES_ACCESSOR]](%swift.type* %"Bas<T, U>") |
| // CHECK: [[T0:%.*]] = bitcast %swift.type* %"Bas<T, U>" to %swift.type*** |
| // CHECK: [[SLOT:%.*]] = getelementptr inbounds %swift.type**, %swift.type*** [[T0]], i64 -2 |
| // CHECK: load %swift.type**, %swift.type*** [[SLOT]], align 8 |
| // CHECK: br |
| // CHECK: store {{.*}} @"$S18field_type_vectors3FooVMf" |
| // CHECK: call %swift.type* @"$S18field_type_vectors3BarVMa"(%swift.type* %T) |
| |
| // CHECK: define{{( protected)?}} private %swift.type** [[ZIM_TYPES_ACCESSOR]](%swift.type* %"Zim<T, U>") |
| // CHECK: [[T0:%.*]] = bitcast %swift.type* %"Zim<T, U>" to %swift.type*** |
| // CHECK: [[SLOT:%.*]] = getelementptr inbounds %swift.type**, %swift.type*** [[T0]], i64 -3 |
| // CHECK: load %swift.type**, %swift.type*** [[SLOT]], align 8 |
| |
| // CHECK: define{{( protected)?}} private %swift.type** [[ZANG_TYPES_ACCESSOR]](%swift.type* %"Zang<V>") |
| // CHECK: [[T0:%.*]] = bitcast %swift.type* %"Zang<V>" to %swift.type*** |
| // CHECK: [[SLOT:%.*]] = getelementptr inbounds %swift.type**, %swift.type*** [[T0]], i64 -3 |
| // CHECK: load %swift.type**, %swift.type*** [[SLOT]], align 8 |
| |