Files
swift-mirror/test/IRGen/weak_class_protocol.sil
Anthony Latsis 17fc00f8a7 [test] IRGen: Adjust FileCheck patterns for new nuw attribute in upstream LLVM
This attribute was introduced in
7eca38ce76d5d1915f4ab7e665964062c0b37697 (llvm-project).

Match it using a wildcard regex, since it is not relevant to these
tests.

This is intended to reduce future conflicts with rebranch.
2025-05-04 03:28:56 +01: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 : $()
}