1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/weaklinked_import_helper.swiftmodule -parse-as-library %S/Inputs/weaklinked_import_helper.swift -enable-library-evolution
//
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir | %FileCheck %s
// UNSUPPORTED: OS=windows-msvc
@_weakLinked import weaklinked_import_helper
// CHECK-DAG: @"$s24weaklinked_import_helper12ConcreteTypeVAA13OtherProtocolAAWP" = extern_weak global ptr
// CHECK-DAG: @"$s24weaklinked_import_helper12ConcreteTypeVMn" = extern_weak global %swift.type_descriptor
// CHECK-DAG: @"$s24weaklinked_import_helper17ProtocolWithAssocMp" = extern_weak global %swift.protocol
// CHECK-DAG: @"$s24weaklinked_import_helper17ProtocolWithAssocP1TAC_AA05OtherD0Tn" = extern_weak global %swift.protocol_requirement
// CHECK-DAG: @"$s1T24weaklinked_import_helper17ProtocolWithAssocPTl" = extern_weak global %swift.protocol_requirement
// CHECK-DAG: @"$s24weaklinked_import_helper17ProtocolWithAssocP1fyyFTq" = extern_weak global %swift.method_descriptor
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper17ProtocolWithAssocPAAE1fyyF"
struct ConformsToProtocolWithAssoc: ProtocolWithAssoc {}
func testTopLevel() {
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper2fnyyF"()
fn()
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper12globalStoredSivg"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper12globalStoredSivs"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper12globalStoredSivM"
let x = globalStored
globalStored = x
globalStored += 1
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper14globalComputedSivg"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper14globalComputedSivs"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper14globalComputedSivM"
let y = globalComputed
globalComputed = y
globalComputed += 1
}
func testStruct() {
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SVMa"
_ = MemoryLayout<S>.size
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SVACycfC"
var s = S()
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SV2fnyyF"
s.fn()
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SV10storedPropSivg"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SV10storedPropSivs"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SV10storedPropSivM"
let x = s.storedProp
s.storedProp = x
s.storedProp += 1
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SV12computedPropSivg"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SV12computedPropSivs"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SV12computedPropSivM"
let y = s.computedProp
s.computedProp = y
s.computedProp += 1
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SVyS2icig"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SVyS2icis"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1SVyS2iciM"
let z = s[0]
s[0] = z
s[0] += 1
}
func testEnum() {
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1EOMa"
_ = MemoryLayout<E>.size
// CHECK-DAG: @"$s24weaklinked_import_helper1EO5basicyA2CmFWC" = extern_weak constant i32
_ = E.basic
// CHECK-DAG: @"$s24weaklinked_import_helper1EO5assocyACSicACmFWC" = extern_weak constant i32
_ = E.assoc(0)
}
func testClass() {
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1CCMa"
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1CCACycfC"
let c = C()
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1CC2fnyyFTj"
c.fn()
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CC10storedPropSivgTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CC10storedPropSivsTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CC10storedPropSivMTj"
let x = c.storedProp
c.storedProp = x
c.storedProp += 1
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CC12computedPropSivgTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CC12computedPropSivsTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CC12computedPropSivMTj"
let y = c.computedProp
c.computedProp = y
c.computedProp += 1
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CCyS2icigTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CCyS2icisTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CCyS2iciMTj"
let z = c[0]
c[0] = z
c[0] += 1
}
// CHECK-DAG: @"$s24weaklinked_import_helper1CCMn" = extern_weak global %swift.type_descriptor
// CHECK-DAG: @"$s24weaklinked_import_helper1CCACycfCTq" = extern_weak global %swift.method_descriptor
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CCACycfc"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1CCfd"
class Sub: C {}
func testProtocolExistential(_ p: P) {
var mutP = p
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1PP2fnyyFTj"
p.fn()
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1PP4propSivgTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1PP4propSivsTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1PP4propSivMTj"
let x = p.prop
mutP.prop = x
mutP.prop += 1
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1PPyS2icigTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1PPyS2icisTj"
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper1PPyS2iciMTj"
let z = p[0]
mutP[0] = z
mutP[0] += 1
}
func testProtocolGeneric<Impl: P>(_ type: Impl.Type) {
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper1PPxycfCTj"
var mutP = type.init()
mutP.fn()
let x = mutP.prop
mutP.prop = x
mutP.prop += 1
let z = mutP[0]
mutP[0] = z
mutP[0] += 1
}
// CHECK-DAG: @"$s24weaklinked_import_helper5BasePMp" = extern_weak global %swift.protocol
protocol RefinesP: BaseP {}
// CHECK-DAG: @"$s24weaklinked_import_helper1SVAA5BasePAAWP" = extern_weak global ptr
// CHECK-DAG: @"$s24weaklinked_import_helper1SVMn" = extern_weak global %swift.type_descriptor
extension S: RefinesP {}
func testInlining() {
// CHECK-DAG: define linkonce_odr hidden {{.+}} @"$s24weaklinked_import_helper22alwaysEmitIntoClientFnyyF"()
// CHECK-DAG: declare extern_weak {{.+}} @"$s24weaklinked_import_helper18usableFromInlineFnyyF"
alwaysEmitIntoClientFn()
}
|