|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// RUN: %target-swift-frontend -wmo -module-name A -emit-irgen -o %t/A1.ll %t/A.swift -enable-experimental-feature Embedded -enable-experimental-feature EmbeddedExistentials -parse-as-library |
| 5 | +// RUN: %FileCheck --check-prefix=A1 %s < %t/A1.ll |
| 6 | + |
| 7 | +// RUN: %target-swift-frontend -wmo -module-name A -num-threads 1 -emit-ir -o %t/A2.ll -o %t/B2.ll %t/A.swift %t/B.swift -enable-experimental-feature Embedded -enable-experimental-feature EmbeddedExistentials -parse-as-library |
| 8 | +// RUN: %FileCheck --check-prefix=A2 %s < %t/A2.ll |
| 9 | +// RUN: %FileCheck --check-prefix=B2 %s < %t/B2.ll |
| 10 | + |
| 11 | +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/A.swiftmodule -wmo -module-name A -emit-ir -o %t/A3.ll %t/A.swift %t/B.swift -enable-experimental-feature Embedded -enable-experimental-feature EmbeddedExistentials -parse-as-library |
| 12 | +// RUN: %FileCheck --check-prefix=A3 %s < %t/A3.ll |
| 13 | + |
| 14 | +// RUN: %target-swift-frontend -wmo -I %t -module-name C -emit-irgen -o %t/C4.ll %t/C.swift -enable-experimental-feature Embedded -enable-experimental-feature EmbeddedExistentials -parse-as-library |
| 15 | +// RUN: %FileCheck --check-prefix=C4 %s < %t/C4.ll |
| 16 | + |
| 17 | +// REQUIRES: swift_in_compiler |
| 18 | +// REQUIRES: optimized_stdlib |
| 19 | +// REQUIRES: swift_feature_Embedded |
| 20 | +// REQUIRES: swift_feature_EmbeddedExistentials |
| 21 | + |
| 22 | + |
| 23 | +//--- A.swift |
| 24 | +public class SomeClass { |
| 25 | +} |
| 26 | + |
| 27 | +public struct SomeStruct { |
| 28 | + var x = 1 |
| 29 | + var y = 2 |
| 30 | +} |
| 31 | + |
| 32 | +public enum SomeEnum { |
| 33 | + case a(Int) |
| 34 | + case b(Float) |
| 35 | +} |
| 36 | + |
| 37 | +//--- B.swift |
| 38 | +public func getSomeClass() -> SomeClass { |
| 39 | + return SomeClass() |
| 40 | +} |
| 41 | + |
| 42 | +public func getSomeStructAsAny() -> Any { |
| 43 | + return SomeStruct() |
| 44 | +} |
| 45 | + |
| 46 | +public func getSomeStruct() -> SomeStruct { |
| 47 | + return SomeStruct() |
| 48 | +} |
| 49 | + |
| 50 | +public func getSomeEnumAsAny() -> Any { |
| 51 | + return SomeEnum.a(1) |
| 52 | +} |
| 53 | + |
| 54 | +public func getSomeEnum()-> SomeEnum { |
| 55 | + return SomeEnum.b(2.0) |
| 56 | +} |
| 57 | + |
| 58 | +//--- C.swift |
| 59 | +import A |
| 60 | +public func useMetadata() -> Any { |
| 61 | + return getSomeClass() |
| 62 | +} |
| 63 | + |
| 64 | +public func useMetadata2() -> Any { |
| 65 | + return getSomeStruct() |
| 66 | +} |
| 67 | + |
| 68 | +public func useMetadata3() -> Any { |
| 69 | + return getSomeEnum() |
| 70 | +} |
| 71 | + |
| 72 | +// Test no reference of metadata. |
| 73 | +// A1-NOT: CMf |
| 74 | + |
| 75 | +// Test reference of metadata. Because we are the defining module metadata is |
| 76 | +// visible outside of the image per current policy. |
| 77 | +// In multiple llvm modules per SIL module mode "Private" SIL linkage becomes |
| 78 | +// hidden linkonce_odr. |
| 79 | +// A2: @"$e1A8SomeEnumOMf" = linkonce_odr hidden constant |
| 80 | +// A2: @"$e1A10SomeStructVMf" = linkonce_odr hidden constant |
| 81 | +// A2: @"$e1A9SomeClassCMf" = linkonce_odr hidden global |
| 82 | + |
| 83 | +// A2: @"$e1A8SomeEnumON" = {{.*}}alias{{.*}}e1A8SomeEnumOMf |
| 84 | +// A2: @"$e1A10SomeStructVN" = {{.*}}alias{{.*}}e1A10SomeStructVMf |
| 85 | +// A2: @"$e1A9SomeClassCN" = {{.*}}alias{{.*}}e1A9SomeClassCMf |
| 86 | + |
| 87 | +// B2: @"$e1A9SomeClassCN" = {{.*}}external{{.*}} global |
| 88 | +// B2: @"$e1A10SomeStructVN" = {{.*}}external{{.*}} global |
| 89 | +// B2: @"$e1A8SomeEnumON" = {{.*}}external{{.*}} global |
| 90 | +// B2: call {{.*}} @"$e1A9SomeClassCACycfC"(ptr swiftself @"$e1A9SomeClassCN") |
| 91 | +// B2: store{{.*}}e1A10SomeStructVN |
| 92 | +// B2: store{{.*}}e1A8SomeEnumON |
| 93 | + |
| 94 | +// Test reference of metadata. Because we are the defining module metadata is |
| 95 | +// visible outside of the image per current policy. |
| 96 | +// In single llvm module per SIL module "Private" SIL linkage makes more |
| 97 | +// intuitive sense. |
| 98 | +// A3: @"$e1A8SomeEnumOMf" = {{.*}}internal constant |
| 99 | +// A3: @"$e1A10SomeStructVMf" = {{.*}}internal constant |
| 100 | +// A3: @"$e1A9SomeClassCMf" = {{.*}}internal global |
| 101 | +// A3: @"$e1A9SomeClassCN" = {{.*}}alias{{.*}}e1A9SomeClassCMf |
| 102 | +// A3: call {{.*}} @"$e1A9SomeClassCACycfC"({{.*}}getelementptr{{.*}}@"$e1A9SomeClassCMf" |
| 103 | + |
| 104 | + |
| 105 | +// Test "external" reference of metadata (defines metadata from another module |
| 106 | +// in current module as linkonce). |
| 107 | +// C4: @"$e1A8SomeEnumOMf" = linkonce_odr hidden constant |
| 108 | +// C4: @"$e1A10SomeStructVMf" = linkonce_odr hidden constant |
| 109 | +// C4: @"$e1A9SomeClassCMf" = linkonce_odr hidden global |
0 commit comments