mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
These were added in https://github.com/swiftlang/swift/pull/81375 (and several other follow-up PRs because we missed a few places) and are no longer needed.
150 lines
5.5 KiB
Plaintext
150 lines
5.5 KiB
Plaintext
// RUN: %target-swift-frontend -swift-version 4 -enforce-exclusivity=checked %s -emit-ir | %FileCheck %s --check-prefix=CHECK
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
class A {
|
|
@_hasStorage var property: Int64 { get set }
|
|
@_hasStorage var exProperty: Any { get set }
|
|
deinit
|
|
init()
|
|
}
|
|
|
|
// CHECK-DAG: [[C:%T14access_markers1AC]] = type
|
|
// CHECK-DAG: [[INT:%Ts5Int64V]] = type <{ i64 }>
|
|
|
|
sil_vtable A {}
|
|
|
|
sil @int_user : $@convention(thin) (Int64, Int64) -> ()
|
|
|
|
// CHECK-LABEL: define {{.*}} @testPaired(
|
|
sil [ossa] @testPaired : $(@guaranteed A) -> () {
|
|
bb0(%0 : @guaranteed $A):
|
|
%func = function_ref @int_user : $@convention(thin) (Int64, Int64) -> ()
|
|
// CHECK: [[SCRATCH1:%.*]] = alloca [[BUFFER:.* x i8.]], align
|
|
// CHECK: [[SCRATCH2:%.*]] = alloca [[BUFFER]], align
|
|
|
|
// CHECK: [[PROPERTY:%.*]] = getelementptr inbounds{{.*}} [[C]], ptr %0, i32 0, i32 1
|
|
%2 = ref_element_addr %0 : $A, #A.property
|
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 {{.*}}, ptr [[SCRATCH1]])
|
|
// CHECK-NEXT: call void @swift_beginAccess(ptr [[PROPERTY]], ptr [[SCRATCH1]], [[SIZE:i(32|64)]] 33, ptr null)
|
|
%3 = begin_access [modify] [dynamic] %2 : $*Int64
|
|
|
|
// CHECK-NEXT: getelementptr inbounds{{.*}} %Ts5Int64V, ptr [[PROPERTY]], i32 0, i32 0
|
|
// CHECK-NEXT: load i64, ptr
|
|
%4 = load [trivial] %3 : $*Int64
|
|
|
|
// CHECK-NEXT: call void @swift_endAccess(ptr [[SCRATCH1]])
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 {{.*}}, ptr [[SCRATCH1]])
|
|
end_access %3 : $*Int64
|
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 {{.*}}, ptr [[SCRATCH2]])
|
|
// CHECK-NEXT: call void @swift_beginAccess(ptr [[PROPERTY]], ptr [[SCRATCH2]], [[SIZE]] 32, ptr null)
|
|
%6 = begin_access [read] [dynamic] %2 : $*Int64
|
|
|
|
// CHECK-NEXT: getelementptr inbounds{{.*}} %Ts5Int64V, ptr [[PROPERTY]], i32 0, i32 0
|
|
// CHECK-NEXT: load i64, ptr
|
|
%7 = load [trivial] %6 : $*Int64
|
|
|
|
// CHECK-NEXT: call void @swift_endAccess(ptr [[SCRATCH2]])
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 {{.*}}, ptr [[SCRATCH2]])
|
|
end_access %6 : $*Int64
|
|
|
|
apply %func(%4, %7) : $@convention(thin) (Int64, Int64) -> ()
|
|
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: define {{.*}}void @testUnpaired(
|
|
sil @testUnpaired : $(@guaranteed A) -> () {
|
|
bb0(%0 : $A):
|
|
// CHECK: [[SCRATCH:%.*]] = alloca [[BUFFER:.* x i8.]], align
|
|
%1 = alloc_stack $Builtin.UnsafeValueBuffer
|
|
|
|
// CHECK: [[PROPERTY:%.*]] = getelementptr inbounds{{.*}} [[C]], ptr %0, i32 0, i32 1
|
|
%2 = ref_element_addr %0 : $A, #A.property
|
|
|
|
// CHECK-NEXT: call void @swift_beginAccess(ptr [[PROPERTY]], ptr [[SCRATCH]], [[SIZE]] 33, ptr null)
|
|
begin_unpaired_access [modify] [dynamic] %2 : $*Int64, %1 : $*Builtin.UnsafeValueBuffer
|
|
|
|
// CHECK-NEXT: call void @swift_endAccess(ptr [[SCRATCH]])
|
|
end_unpaired_access [dynamic] %1 : $*Builtin.UnsafeValueBuffer
|
|
|
|
// CHECK-NEXT: call void @swift_beginAccess(ptr [[PROPERTY]], ptr [[SCRATCH]], [[SIZE]] 32, ptr null)
|
|
begin_unpaired_access [read] [dynamic] %2 : $*Int64, %1 : $*Builtin.UnsafeValueBuffer
|
|
|
|
// CHECK-NEXT: call void @swift_endAccess(ptr [[SCRATCH]])
|
|
end_unpaired_access [dynamic] %1 : $*Builtin.UnsafeValueBuffer
|
|
|
|
dealloc_stack %1 : $*Builtin.UnsafeValueBuffer
|
|
|
|
%20 = tuple ()
|
|
return %20 : $()
|
|
}
|
|
|
|
sil @writeEmptyTuple : $(@inout ()) -> ()
|
|
sil @readEmptyTuple : $(@in_guaranteed ()) -> ()
|
|
|
|
// rdar://32039394 - Don't apply dynamic enforcement to empty types.
|
|
// CHECK-LABEL: define {{.*}}void @testPairedBox(
|
|
sil @testPairedBox : $(@guaranteed { var () }) -> () {
|
|
bb0(%0 : ${ var () }):
|
|
// CHECK: entry:
|
|
%2 = project_box %0 : ${ var () }, 0
|
|
// CHECK-NEXT: call {{.*}}void @writeEmptyTuple(ptr captures(none) undef)
|
|
%3 = begin_access [modify] [dynamic] %2 : $*()
|
|
%write_fn = function_ref @writeEmptyTuple : $@convention(thin) (@inout ()) -> ()
|
|
apply %write_fn(%3) : $@convention(thin) (@inout ()) -> ()
|
|
end_access %3 : $*()
|
|
|
|
// CHECK-NEXT: call {{.*}}void @readEmptyTuple(ptr noalias captures(none) undef)
|
|
%5 = begin_access [read] [dynamic] %2 : $*()
|
|
%read_fn = function_ref @readEmptyTuple : $@convention(thin) (@in_guaranteed ()) -> ()
|
|
apply %read_fn(%5) : $@convention(thin) (@in_guaranteed ()) -> ()
|
|
end_access %5 : $*()
|
|
|
|
// CHECK-NEXT: ret void
|
|
%20 = tuple ()
|
|
return %20 : $()
|
|
}
|
|
|
|
// rdar://31964550
|
|
// Just check that this doesn't crash.
|
|
sil @testCopyAddr : $(@guaranteed A) -> () {
|
|
bb0(%0 : $A):
|
|
%1 = alloc_stack $Any
|
|
%2 = ref_element_addr %0 : $A, #A.exProperty
|
|
%3 = begin_access [dynamic] [read] %2 : $*Any
|
|
copy_addr %2 to [init] %1 : $*Any
|
|
end_access %3 : $*Any
|
|
destroy_addr %1 : $*Any
|
|
dealloc_stack %1 : $*Any
|
|
%20 = tuple ()
|
|
return %20 : $()
|
|
}
|
|
|
|
// CHECK-LABEL: define {{.*}}void @testNontracking(
|
|
sil @testNontracking : $(@guaranteed A) -> () {
|
|
bb0(%0 : $A):
|
|
%1 = alloc_stack $Int64
|
|
// CHECK: [[PROPERTY:%.*]] = getelementptr inbounds{{.*}} [[C]], ptr %0, i32 0, i32 1
|
|
%2 = ref_element_addr %0 : $A, #A.property
|
|
// CHECK: call void @swift_beginAccess(ptr %{{.*}}, ptr %{{.*}}, [[SIZE]] 0, ptr null)
|
|
%3 = begin_access [read] [dynamic] [no_nested_conflict] %2 : $*Int64
|
|
copy_addr %3 to [init] %1 : $*Int64
|
|
// CHECK-NOT: end_access
|
|
end_access %3 : $*Int64
|
|
%9 = alloc_stack $Builtin.UnsafeValueBuffer
|
|
// CHECK: call void @swift_beginAccess(ptr %{{.*}}, ptr %{{.*}}, [[SIZE]] 0, ptr null)
|
|
begin_unpaired_access [read] [dynamic] [no_nested_conflict] %2 : $*Int64, %9 : $*Builtin.UnsafeValueBuffer
|
|
copy_addr %2 to %1 : $*Int64
|
|
dealloc_stack %9 : $*Builtin.UnsafeValueBuffer
|
|
dealloc_stack %1 : $*Int64
|
|
%20 = tuple ()
|
|
return %20 : $()
|
|
}
|