Files
swift-mirror/test/IRGen/weak_class_protocol.sil
Alex Lorenz 4858cb6225 [IRGen][interop] do not add 'nocapture' to not bitwise takable types
The use of 'nocapture' for parameters and return values is incorrect for C++ types, as they can actually capture a pointer into its own value (e.g. std::string in libstdc++)

rdar://115062687
2023-09-25 17:43:34 -07:00

26 lines
1.2 KiB
Plaintext

// 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(ptr noalias sret({{.*}}) %0, i64 %1, i64 %2) {{.*}} {
// CHECK: entry:
// CHECK-objc: [[INSTANCE:%.*]] = inttoptr i64 %1 to ptr
// CHECK-native: [[INSTANCE:%.*]] = inttoptr i64 %1 to ptr
// CHECK: [[WTABLE:%.*]] = inttoptr i64 %2 to ptr
// CHECK: [[WTABLE_SLOT:%.*]] = getelementptr inbounds { %swift.weak, ptr }, ptr %0, i32 0, i32 1
// CHECK: store ptr [[WTABLE]], ptr [[WTABLE_SLOT]], align 8
// CHECK: [[INSTANCE_SLOT:%.*]] = getelementptr inbounds { %swift.weak, ptr }, ptr %0, i32 0, i32 0
// CHECK-objc: call ptr @swift_unknownObjectWeakAssign(ptr returned [[INSTANCE_SLOT]], ptr [[INSTANCE]]) {{#[0-9]+}}
// CHECK-native: call ptr @swift_weakAssign(ptr returned [[INSTANCE_SLOT]], ptr [[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 : $()
}