Files
swift-mirror/test/IRGen/exclusivity.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

54 lines
2.0 KiB
Plaintext

// RUN: %target-swift-frontend %s -swift-version 4 -emit-ir -enforce-exclusivity=checked | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s
sil_stage canonical
import Swift
class A {
@_hasStorage final var x: Int { get set }
init(x: Int)
}
sil_vtable A {}
sil public_external @changeInt : $@convention(thin) (@inout Int) -> ()
// CHECK-LABEL: define {{.*}} @test1(
sil @test1 : $@convention(thin) (@owned A) -> Int {
bb0(%0 : $A):
// CHECK: [[SCRATCH0:%.*]] = alloca [[BUFFER_T:\[.* x i8\]]],
// CHECK: [[SCRATCH1:%.*]] = alloca [[BUFFER_T:\[.* x i8\]]],
// CHECK: [[PROP:%.*]] = getelementptr inbounds{{.*}} [[C:%T11exclusivity1AC]], ptr %0, i32 0, i32 1
%3 = ref_element_addr %0 : $A, #A.x
// CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr [[SCRATCH0]])
// CHECK: call void @swift_beginAccess(ptr [[PROP]], ptr [[SCRATCH0]], [[SIZE_T:i32|i64]] 32, ptr null)
%4 = begin_access [read] [dynamic] %3 : $*Int
// CHECK: [[T0:%.*]] = getelementptr inbounds{{.*}} [[INT:%TSi]], ptr %1, i32 0, i32 0
// CHECK: load {{(i64|i32)}}, ptr [[T0]]
%5 = load %4 : $*Int
// CHECK: call void @swift_endAccess(ptr [[SCRATCH0]])
// CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr [[SCRATCH0]])
end_access %4 : $*Int
%9 = function_ref @changeInt : $@convention(thin) (@inout Int) -> ()
// CHECK: [[PROP:%.*]] = getelementptr inbounds{{.*}} [[C:%T11exclusivity1AC]], ptr %0, i32 0, i32 1
%11 = ref_element_addr %0 : $A, #A.x
// CHECK: call void @llvm.lifetime.start.p0(i64 -1, ptr [[SCRATCH1]])
// CHECK: call void @swift_beginAccess(ptr [[PROP]], ptr [[SCRATCH1]], [[SIZE_T:i32|i64]] 33, ptr null)
%12 = begin_access [modify] [dynamic] %11 : $*Int
// CHECK: call {{.*}} @changeInt(ptr{{.*}} [[PROP]])
%13 = apply %9(%12) : $@convention(thin) (@inout Int) -> ()
// CHECK: call void @swift_endAccess(ptr [[SCRATCH1]])
// CHECK: call void @llvm.lifetime.end.p0(i64 -1, ptr [[SCRATCH1]])
end_access %12 : $*Int
strong_release %0 : $A
return %5 : $Int
}