blob: 7fc0aee0377c92f0010c6d60c41baa99300392b1 [file] [log] [blame]
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
// REQUIRES: CPU=x86_64
import Swift
protocol Foo: class { }
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @store_weak({ %swift.weak, i8** }* noalias nocapture sret, i64, i64) {{.*}} {
// CHECK: entry:
// CHECK-objc: [[INSTANCE:%.*]] = inttoptr i64 %1 to %objc_object*
// CHECK-native: [[INSTANCE:%.*]] = inttoptr i64 %1 to %swift.refcounted*
// CHECK: [[WTABLE:%.*]] = inttoptr i64 %2 to i8**
// CHECK: [[WTABLE_SLOT:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 1
// CHECK: store i8** [[WTABLE]], i8*** [[WTABLE_SLOT]], align 8
// CHECK: [[INSTANCE_SLOT:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
// CHECK-objc: call %swift.weak* @swift_unknownObjectWeakAssign(%swift.weak* returned [[INSTANCE_SLOT]], %objc_object* [[INSTANCE]]) {{#[0-9]+}}
// CHECK-native: call %swift.weak* @swift_weakAssign(%swift.weak* returned [[INSTANCE_SLOT]], %swift.refcounted* [[INSTANCE]]) {{#[0-9]+}}
// CHECK: ret void
// CHECK: }
sil @store_weak : $@convention(thin) (@owned Foo?) -> @out @sil_weak Foo? {
entry(%w : $*@sil_weak Foo?, %x : $Foo?):
store_weak %x to %w : $*@sil_weak Foo?
return undef : $()
}