Files
swift-mirror/test/IRGen/indirect_enum.sil
Slava Pestov b49a4525c3 SIL: Only give type metadata public linkage if -sil-serialize-all is on
Otherwise, any types referenced from transparent functions must be
public or @_versioned.
2016-03-28 14:14:50 -07:00

51 lines
1.9 KiB
Plaintext

// RUN: %target-swift-frontend -emit-ir %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
import Swift
// CHECK-64: @_TWVO13indirect_enum5TreeA = hidden constant {{.*}} i8* inttoptr ([[WORD:i64]] 8 to i8*), i8* inttoptr (i64 2162695 to i8*), i8* inttoptr (i64 8 to i8*)
// CHECK-32: @_TWVO13indirect_enum5TreeA = hidden constant {{.*}} i8* inttoptr ([[WORD:i32]] 4 to i8*), i8* inttoptr (i32 2162691 to i8*), i8* inttoptr (i32 4 to i8*)
// CHECK-LABEL: define{{( protected)?}} private %swift.type** @get_field_types_TreeA
// -- Leaf(T)
// CHECK: [[BITS:%.*]] = ptrtoint %swift.type* %T to [[WORD]]
// CHECK: [[INDIRECT_FLAG:%.*]] = or [[WORD]] [[BITS]], 1
// -- Branch(TreeA, TreeA)
// CHECK: [[TUPLE:%.*]] = call %swift.type* @swift_getTupleTypeMetadata2
// CHECK: [[BITS:%.*]] = ptrtoint %swift.type* [[TUPLE]]
// CHECK: [[INDIRECT_FLAG:%.*]] = or [[WORD]] [[BITS]], 1
indirect enum TreeA<T> {
case Nil
case Leaf(T)
case Branch(left: TreeA<T>, right: TreeA<T>)
}
// CHECK-LABEL: define{{( protected)?}} private %swift.type** @get_field_types_TreeB
// -- Leaf(T)
// CHECK-NOT: ptrtoint %swift.type* %T
// -- Branch(TreeA, TreeA)
// CHECK: [[TUPLE:%.*]] = call %swift.type* @swift_getTupleTypeMetadata2
// CHECK: [[BITS:%.*]] = ptrtoint %swift.type* [[TUPLE]]
// CHECK: [[INDIRECT_FLAG:%.*]] = or [[WORD]] [[BITS]], 1
enum TreeB<T> {
case Nil
case Leaf(T)
indirect case Branch(left: TreeB<T>, right: TreeB<T>)
}
// CHECK-LABEL: define{{( protected)?}} private %swift.type** @get_field_types_Foo
// -- Foo(Int)
// CHECK-64: (i64 or (i64 ptrtoint (%swift.type* @_TMSi {{.*}}), [[WORD]] 1)
// CHECK-32: (i32 or (i32 ptrtoint (%swift.type* @_TMSi {{.*}}), [[WORD]] 1)
// -- Bar(T)
// CHECK-NOT: ptrtoint %swift.type* %T
enum Foo<T> {
indirect case Foo(Int)
case Bar(T)
}
// rdar://problem/22169679
enum E<T> {
indirect case A(E)
case B(T)
}